目录
- 一、问题
- 二、解决方法
- 1.application.properties配置
- 2.模板文件头
- 3.模板文件内容
一、问题
我们使用springboot和Thymeleaf的时候可能会报下面的错误:
Exception processing template “index”: An errpythonor happened during template parsing (template: “class path resource [templates/index.html]”)
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: “class path resource [tjavascript开发者_Python教程emplates/index.html]”)
二、解决方法
在springboot后端代码没有写错的前提下:
@Controller public class HelloController { @RequestMapping("/") public String index() { return "index"; } }
1.application.properties配置
注意:一般情况下,问题不会来自于application.properties配置,默认不用配置即可,则选用模板路径为http://www.devze.com:spring.thymeleaf.prefix=classpath:/templates/
但是如果配置了该选项,修改了默认路径,记得创建对应路径。
2.模板文件头
保证html文件头为:
<!DOCTYPE html> <html lang="en">
或者选用html约束
<!DOCTYPE html> <html XMLns:th="http://wwww.devze.comww.thymeleaandroidf.org">
3.模板文件内容
我们在导入写好的html文件之后一般有几个问题:
1.html文件头约束,也就是上面的问题
2.html标签闭合
3.Thymeleaf的引用需要修改,如一些form表单
以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。
精彩评论