服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - Spring Boot 2.0 设置网站默认首页的实现代码

Spring Boot 2.0 设置网站默认首页的实现代码

2021-04-19 13:30tiandong Java教程

这篇文章主要介绍了Spring Boot 2.0 设置网站默认首页的实现代码,需要的朋友可以参考下

spring boot设置默认首页,方法实验ok如下

附上application启动代码

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @classname application
* @description spring-boot website启动类
* @author kevin.tian
* @date 2018-03
* @version 1.0.0
*/
@springbootapplication
@propertysource(value={ 
"file:${app_home_conf}/overpayment-web/overpayment-web.properties"
"file:${app_home_conf}/overpayment-web/db.properties"
})
@importresource({"file:${app_home_conf}/overpayment-web/spring.xml"})
public class application extends springbootservletinitializer {
public static void main(string[] args)
{
try {
springapplication.run(application.class);
} catch (exception e) {
// todo: handle exception
e.printstacktrace();
}
}
}

1. 放置默认首页default.html,

位置在/src/main/resources/static/default.html

2. 增加indexcontroller控制器,设置index路由

Spring Boot 2.0 设置网站默认首页的实现代码

测试结果,如下

Spring Boot 2.0 设置网站默认首页的实现代码

下面看下spring boot 2.0 新特性

说了这么多,spring boot 2.0 和 1.0 比都有哪些变动和新特性呢?

•jdk最低要求1.8+,并支持1.9;
•支持spring webflux/webflux.fn响应式的web编程;
•提供spring data cassandra, mongodb, couchbase和redis的响应式自动配置及starter poms;
•支持嵌入式的netty;
•http/2的支持:tomcat, undertow and jetty;
•全新的体系结构,支持spring mvc、webflux和jersey;
•增强了micrometer集成,以atlas, datadog, ganglia, graphite, influx, jmx, new relic, prometheus, signalfx, statsd and wavefront为基础的度量指标;
•quartz调度支持;
•极大简化了安全自动配置;

总结

以上所述是小编给大家介绍的spring boot 2.0 设置网站默认首页的实现代码,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:http://www.cnblogs.com/itshare/p/8694595.html

延伸 · 阅读

精彩推荐