spring boot项目如果要展示静态页面,可以把html、js、css等文件放在resources目录下的static或public目录里面(如果没有可以直接创建)。
比如:
index.html的内容如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>spring boot index</title>
</head>
<body>
Hello, welcome to my spring Boot!
</body>
</html>
结果:
Hello, welcome to my spring Boot!
另外,需要先引入web相关的依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
如果想修改tomcat的缺省端口,还得在application.yml文件中配置一下:
server:
port: 8082
源代码地址:https://github/xujijun/my-spring-boot
更多推荐
spring boot 静态页面展示
发布评论