springboot默认的欢迎页面设置

1.新建MVCConfiguration类,代码如下:

package com.example.demohebirnate.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class MVCConfiguration extends WebMvcConfigurerAdapter {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {

        registry.addViewController("/").setViewName("forward:/login.html");

        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);

        super.addViewControllers(registry);

    }
}

2.新建login.html,目录为:resources/static   这里默认是static目录下,原因不详

springboot默认的欢迎页面设置_第1张图片

3.访问地址:http://localhost:8080/,如图:

springboot默认的欢迎页面设置_第2张图片

 

你可能感兴趣的:(springboot)