在使用spring boot搭建项目的时候报错:
Error resolving template template might not exist or might not be accessible
解决方法:
情况1:
public String thymeleaf(Model model){
model.addAttribute("name", "mark");
return "hello ";
}
仔细观察后发现:
"hello "中多了一个空格..改成“hello”即OK。
情况2:
public String thymeleaf(Model model){
model.addAttribute("name", "mark");
return "/hello";
}
在springboot中使用thymeleaf不需要加“/xxxx”
同样的改成:
public String thymeleaf(Model model){
model.addAttribute("name", "mark");
return "hello";
}
就OK
博客讲述使用Spring Boot搭建项目时出现模板解析错误,提示模板可能不存在或不可访问。给出两种解决方法,一是检查代码中是否存在多余空格,如将“hello ”改为“hello”;二是在使用Thymeleaf时不要加“/xxxx”。
1336

被折叠的 条评论
为什么被折叠?



