[英]How to debug org.thymeleaf.exceptions.TemplateInputException?
I have a new project and it's my first time using spring MVC and Thymeleaf. 我有一个新项目,这是我第一次使用Spring MVC和Thymeleaf。 The error message that I'm getting seems obvious:
我收到的错误消息似乎很明显:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
I have googled a lot and saw many people with similar issues. 我在Google上搜索了很多,看到很多人遇到类似的问题。 However, none of the solutions helped me find out why my setup does not work.
但是,这些解决方案都无法帮助我找出为什么我的设置无法正常工作的原因。
Instead of classpath:/templates
I have also tried variations like templates
and /templates
除了
classpath:/templates
我还尝试了templates
和/templates
之classpath:/templates
变体
some questions: 一些问题:
edit On line 23 in the document on the right (BetterCommuteApplication.java) you can see that Intellij is able to resolve the reference to my template file. 编辑右侧文档(BetterCommuteApplication.java)中的第23行,您可以看到Intellij能够解析对我的模板文件的引用。
This screenshot shows my configuration and I think it should suffice as enough information to get the answer. 此屏幕快照显示了我的配置,我认为它足以提供足够的信息来获得答案。
Thank you for your time! 感谢您的时间! :-)
:-)
ugh, I tried to combine Spring boot with thymeleaf manually here. ug,我尝试在此处手动将Spring Boot与thymeleaf结合使用。 (I'm used to developing back-ends ^^") This doesn't make much sense as initialising spring MVC does this right out of the box.
(我习惯于开发后端^^“)这没有多大意义,因为初始化spring MVC可以立即使用。
The solution was to init this as springMVC, use @Controller
instead of @ Restcontroller
because I want the class to be handled as MVC class... and the return could be as simple as return 'index'
(because my html file in the default location is called index.html) 解决方案是将其初始化为springMVC,使用
@Controller
而不是@ Restcontroller
因为我希望将该类作为MVC类进行处理...并且返回可能像Restcontroller
return 'index'
一样简单(因为默认情况下我的html文件)该位置称为index.html)
basically I would have known, if I'd simply followed the tutorial on SpringMVC. 如果我只是遵循SpringMVC上的教程 ,那么我基本上就会知道。 .. but hey, why would anyone RTFM?
..但是,嘿,为什么有人要RTFM? :-)
:-)
so it looks like this: 所以看起来像这样:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.