通常情况下,一个web应用都会有一个webapp目录。但是springboot构建的web应用没有webapp,先看springboot构建的web项目的目录结构:
src下的resource下有static和templates,这是springboot用于存放页面静态文件的目录。通常情况下,springboot使用Thymeleaf组建做动态页面,而不是使用jsp。
static主要存放图片样式文件.css和js等,而template主要存放页面文件。
访问静态资源
pom.xml加入
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
html页面
控制器:
浏览器:
端口被设置成了80

本文介绍了SpringBoot Web项目的目录结构特点,指出SpringBoot项目不使用传统的webapp目录,而是采用src/main/resources下的static和templates来存放静态资源和页面文件。文章还详细解释了如何配置Thymeleaf作为视图引擎,并提供了html页面控制器的实例。
2317

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



