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目录下,原因不详

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

猜你喜欢

转载自blog.csdn.net/qq_29477175/article/details/82117177