今天出了一个bug,如下图(我使用的是spring boot框架)
status:500 exception:org.thymeleaf.exceptions.TemplateInputExceptionIDEA的控制台也随之报错:
status:500 exception:org.thymeleaf.exceptions.TemplateInputExceptionERROR 18160 — [nio-8080-exec-4] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-4] Exception processing template “error/5xx”: An error happened during template parsing

在此总结一下出错原因以及解决办法:
出错的根本原因在于控制层中传过去的model与页面它不匹配
比如:(其中id自增长策略)
status:500 exception:org.thymeleaf.exceptions.TemplateInputExceptionaddresearch页面:
status:500 exception:org.thymeleaf.exceptions.TemplateInputException这里只有四项,且是与数据库匹配的

而在addcourse页面
status:500 exception:org.thymeleaf.exceptions.TemplateInputException
很明显这两个页面传值所传到的数据库不一致
如果最后的addresearch写成了addcourse则会出现以上的错误

同样的,如果model.addAttribute(“research”, new Research(null, null, null, null,null));一句中的research被改成course
那么addresearch中的status:500 exception:org.thymeleaf.exceptions.TemplateInputExceptionuserModel.research它将无值,也会导致出现这个错误
这虽然只是拼写错误,但是确实会引发这个500错误
错的很蠢,但是错误原因值得深思
特此记录,不是说以后不会犯拼写类的错误,而是希望自己能对错误原因有一定了解

本小白写博客,可能看得很迷惑,还请大神们轻喷

相关文章:

  • 2021-04-16
  • 2021-09-06
  • 2022-12-23
  • 2022-01-03
  • 2022-01-11
  • 2021-07-09
  • 2021-09-19
猜你喜欢
  • 2021-04-25
  • 2021-10-01
  • 2021-08-29
  • 2021-08-17
  • 2021-08-17
  • 2021-09-17
  • 2021-04-18
相关资源
相似解决方案