spring boot 静态页面展示
2016-06-28 17:30
483 查看
spring boot项目如果要展示静态页面,可以把html、js、css等文件放在resources目录下的static或public目录里面(如果没有可以直接创建)。
比如:
index.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
比如:
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
相关文章推荐
- 使用nodejs、Python写的一个简易HTTP静态文件服务器
- nginx win32 版本静态文件测试 (Windows环境)
- PHP合并静态文件详解
- PHP静态文件生成类实例
- php静态文件返回304技巧分享
- Djang中静态文件配置方法
- Spring boot中使用MyBatis Generator
- Spring boot Jetty 服务器相比tomcat的一些不足
- 使用了Spring boot devtools, dozer转换嵌套对象失败解决记录
- Springfox swagger-ui 覆盖默认request host
- Spring Boot学习笔记-快速示例
- Spring Boot学习笔记—日志
- Spring Boot学习笔记-SQL数据库使用
- Spring Boot学习笔记-错误处理及自定义
- Spring Boot学习笔记-外部化属性配置
- 使用Spring Boot Gradle 打war包的一点心得体会
- spring boot和mybatis整合
- Spring-boot生成可执行jar包
- 如何在django里使用静态文件
- spring-boot 所有的配置