There was an unexpected error (type=Internal Server Error, status=500).

这篇具有很好参考价值的文章主要介绍了There was an unexpected error (type=Internal Server Error, status=500).。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

There was an unexpected error (type=Internal Server Error, status=500).

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: “class path resource [templates/main.html]”)
这个错误原因在于模板上的有些数据异常导致的:

问题描述

在开发springboot的时候,进行modelAndView 视图层映射的时候,一直出现

An error happened during template parsing (template: "class path resource [templates/index.html]")

模板解析过程中发生错误(模板:“类路径资源[templates/index.html]”)

在参考各位大佬的错误后得到三条解决办法:
方法一、配置文件问题

    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.servlet.content-type=text/html
    spring.thymeleaf.encoding=utf-8
    spring.thymeleaf.mode=LEGACYHTML5
    spring.thymeleaf.cache=false
    spring.mvc.static-path-pattern=/**
    spring.resources.static-locations=classpath:/static/
方法二、@RestController

@Controller和@RestController功能不一样,将@Controller修改为@RestController在加上@ResponseBody
方法三:

在pom.xml文件下的build配置(都不是这个错误的解决方案)

    <resources>
        <resource>
            <directory>sre/main/resources</directory>
        </resource>
    </resources>

因为加了

    https: xmlns:https="http://www.w3.org/1999/xhtml"
    和
    xmlns:th="http://www.thymeleaf.org"

但是:我竟然是实体类上的FromId拼写错误了(拼写成Form了),导致数据库查询后映射不到FromId。在测试查询时竟然也没有仔细看。最后在仔细地一步一步调试中终于找到了。

所以写代码一定要仔细仔细在仔细。(浪费了大半天的时间真是欲哭无泪)!
 文章来源地址https://www.toymoban.com/news/detail-701011.html

到了这里,关于There was an unexpected error (type=Internal Server Error, status=500).的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【已解决】WARNING: There was an error checking the latest version of pip.报错问题

    今天在用python的时候出现了WARNING: There was an error checking the latest version of pip.问题。 顾名思义:警告:检查最新版本的pip时出错。 那么很明显问题是没有用最新版本的pip。那找到问题的话就直接上解决方法吧。 更新pip包即可,正常更新就行。然后就能安装了。 1、执行命令前

    2024年02月09日
    浏览(57)
  • WARNING: There was an error checking the latest version of pip.报错及解决方法

    警告:检查最新版本的pip时出错。   需要升级pip版本才可以安装其他模块,我们只需要升级pip 在命令操作窗口输入python -m pip install --upgrade pip Successfully uninstalled pip-19.1.1(成功卸载旧版本:22.3.1) Successfully installed pip-20.0.2(成功安装新版本:23.0.1)   在命令操作窗口输入

    2024年02月05日
    浏览(53)
  • An unexpected connection driver error occured

    安装下载好rabbitmq,我在springboot整合mq,启动的时候报错了 An unexpected connection driver error occured 后来又报 Failed to check/redeclare auto-delete queue(s). 综合就是连接问题,端口有问题 我试过添加账户,提高权限,都没用,参考了 https://blog.csdn.net/weixin_43933728/article/details/124691726 最后发

    2024年02月11日
    浏览(68)
  • yarn报错 error An unexpected error occurred httpsregistry.yarnpkg.com...

    1. 报错原因 使用yarn命令安装依赖包时报错,提示信息: error An unexpected error occurred: \\\"https://registry.yarnpkg.com/killable/-/killable-1.0.0.tgz: connect ETIMEDOUT 104.16.19.35:443\\\" 这是由于资源地址请求超时造成的,需要更换一下请求地址。 2. 解决方案 将资源地址设置为淘宝镜像: 查看当前镜像

    2024年02月12日
    浏览(51)
  • 解决方案:yarn 出现error An unexpected error occurred错误的解决办法

    yarn 相比于 npm 、 cnpm 、 npx 来说,效率很高,是前端工程师首选的 包管理 工具,但今日在项目中遇到一个问题,让人很是头疼,看一下报错: 网上搜索解决方案,查阅了一下yarn官方文档,查找到一种解决方法 相信出现类似的情况,会帮助到大家!!!

    2024年02月05日
    浏览(75)
  • QMimeDatabase: Error loading internal MIME data An error has been encountered at line 1 of <internal

    QMimeDatabase: Error loading internal MIME data An error has been encountered at line 1 of : Premature end of document.: Traceback (most recent call last): File “D:anacondalibsite-packageslibscanvas.py”, line 530, in paintEvent p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) TypeError: arguments did not match any overlo

    2024年02月06日
    浏览(37)
  • Java连rabbitMQ 报错 An unexpected connection driver error occured

    Java 项目中连接不上 rabbitMQ,报错内容如下 An unexpected connection driver error occured   是 发生意外的连接驱动程序错误 最大的可能是 新建的用户 没有 授权 一、 要确认  服务器安装上mq之后默认端口15672是浏览器浏览的端口,项目中则是需要配置成5672 二、新建用户需要授权 

    2024年02月12日
    浏览(53)
  • error An unexpected error occurred: “https://registry.npmmirror.com/moment: tunneling socket could n

    yarn install 的时候报了错误 解决方法 我换了原来的镜像 yarn 不行就换npm,确保都换了,然后这个报错就可以解决了 如果还不行的,检查你的代理地址是否正确,是否防火墙影响

    2024年02月04日
    浏览(37)
  • ES 通过查询更新某个字段,Error 500 (Internal Server Error)

    问题描述: 项目中通过查询ES中某个字段,并更新某个值的字段,当量比较大的时候报错: upsert associated failed: elastic: Error 500 (Internal Server Error): Failed to compile inline script [ctx._source.pcap_filename = ] using lang [painless] [type=general_script_exception] 问题解析: 1. 通过查询某个字段并更新这

    2024年02月03日
    浏览(38)
  • rabbitmq连接特别慢 一直连接超时 An unexpected connection driver error occured

    连接linux上的rabbitmq时,特别慢一直出现An unexpected connection driver error occured 或者 连接超时等异常。如下: 造成这个问题的原因大概有三种: 一、配置文件rabbitmq端口号错误,端口后应该写成5672   二、权限问题,登录rabbitmq,查看用户权限。如下: 像这个shop一样就可以了,如

    2024年02月15日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包