您的位置:首页 > 编程语言 > Java开发

spring boot 静态页面展示

2016-06-28 17:30 483 查看
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>


访问:http://localhost:8082/

结果:
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.com/xujijun/my-spring-boot
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息