版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AinUser/article/details/81937762
spring boot访问页面需要thymeleaf模板依赖
在pom文件中引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
1.直接访问页面
你只需要创建一个新的html文件 放到resource目录下的static目录下即可
然后直接localhost:8888/*.html(*代指的是你的页面名称)
2.通过控制层访问页面
此时你的页面应该放的位置templates目录下(同理:如果你没有该目录,你可以自行创建即可)
在controller文件中
@Controller
@RequestMapping("demo")
public class Demo {
@RequestMapping("/demo")
public String demo(){
return "demo3";
} }
访问:localhost:8080/demo/demo即可