我在整合的过程中遇到了好多坑,还好,一一解决,如果你也遇到坑了,不要怕,看过来
1.在pom中引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.4.3.RELEASE</version>
</dependency>
2.在引入配置文件方面
thymeleaf:
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
注意不要有空格
3.后台路径上
@Controller
public class LoginController extends BaseController {
@RequestMapping(value = "/save")
public String save(String mol,Model model){
model.addAttribute("testId",mol);
return "index";
}
}
不要用@RestController,RequestMapping里边不要有指定这是get方法,或者post方法的那个什么什么
4.在页面上如果你发现你用不了thymleaf的标签,你就要在html开头
引入<html xmlns:th="http://www.thymeleaf.org">
5.如果找不到404,看看自己的路径
6.ok了,