Spring Boot 2.0 设置网站默认首页


Spring Boot设置默认首页,方法实验OK如下

附上Application启动代码

/**
 * @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路由

 

测试结果,如下

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM