简体   繁体   English

如何调试org.thymeleaf.exceptions.TemplateInputException?

[英]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/templatesclasspath:/templates变体

some questions: 一些问题:

  • What is the "basedir" from which the relative path is being looked for? 从中寻找相对路径的“ basedir”是什么?
  • Is it possible to run spring in debug to see how these kind of configurations are set? 是否可以在调试中运行spring来查看如何设置此类配置? ie call when I call localhost:8080 and there's a breakpoint somewhere: would it be possible to see how the file index.html is being looked for? 也就是说,当我调用localhost:8080并在某个地方有断点时调用:是否可以查看正在寻找index.html文件的方式?

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.

相关问题 Thymeleaf:org.thymeleaf.exceptions.TemplateInputException - Thymeleaf : org.thymeleaf.exceptions.TemplateInputException org.thymeleaf.exceptions.TemplateInputException:Spring Boot - org.thymeleaf.exceptions.TemplateInputException: Spring Boot springboot项目的问题:org.thymeleaf.exceptions.TemplateInputException - issue with springboot project : org.thymeleaf.exceptions.TemplateInputException Thyemleaf 嵌套迭代触发器 org.thymeleaf.exceptions.TemplateInputException - Thyemleaf nested iteration triggers org.thymeleaf.exceptions.TemplateInputException 如何摆脱 org.thymeleaf.exceptions.TemplateInputException: 同时使用 thymeleaf 表达式以引导卡的形式打印数据? - how to get rid of org.thymeleaf.exceptions.TemplateInputException: while using thymeleaf expression to print data in form of bootstrap cards? org.thymeleaf.exceptions.TemplateInputException:解决片段错误:无法解析模板或片段 - org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: template or fragment could not be resolved 我的spring-boot应用程序给出以下错误“ org.thymeleaf.exceptions.TemplateInputException:” - My spring-boot app gives the following error “org.thymeleaf.exceptions.TemplateInputException:” org.thymeleaf.exceptions.TemplateInputException:异常分析文档:template =“ login”,第36行-第3列 - org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template=“login”, line 36 - column 3 org.thymeleaf.exceptions.TemplateProcessingException:串联 href - org.thymeleaf.exceptions.TemplateProcessingException: Concatenation href Spring 启动测试 Thymeleaf org.thymeleaf.exceptions.TemplateProcessingException - Spring Boot Testing Thymeleaf org.thymeleaf.exceptions.TemplateProcessingException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM