1.首先查看controller是否有效
启动类AlianApplication.class必须和controller控制器在同一个包下面,才会对@controller进行扫面添加到容器中去。
2.是否添加thymeleaf的坐标依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency>
3.application.properties路径访问解析
spring.thymeleaf.prefix=classpath:/templates/ #默认路径 spring.thymeleaf.suffix=.html #默认添加文件后缀 spring.thymeleaf.servlet.content-type=text/html spring.thymeleaf.encoding=UTF-8
4.可以成功启动。