一、 报错信息
这时候检查
检查:
.html文件中的users是否和Controller文件对应(users)
如果上述还没问题 users下面会有一个小的波浪线
但是运行时候还无影响
可以尝试关闭thymeleaf的提示
二 、可能原因是:
idea 对 thymeleaf 模板校验问题。
三、另一类错误
在Spring boot项目中,整合Thymeleaf模板引擎,在html文件中使用th:text="${msg}"
属性标签时,提示报错“无法解析msg”。
th:text="${msg}"
加下面写的注释就可以取消掉msg下面红色的波浪线
或者还可以把String改成Object
@Controller
public class ThymeleafController {
@GetMapping("/home")
public String test1(Model model){
model.addAttribute("msg", "Welcome to home page! Enjoy yourself,please!");
return "home";
}
}
改成这个样子
@Controller
public class ThymeleafController {
@GetMapping("/home")
public Object test1(Model model){
model.addAttribute("msg", "Welcome to home page! Enjoy yourself,please!");
return "home";
}
}