如何设置SpringBoot项目默认访问页面

package com.rongpan.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.WebMvcConfigurer;


@Configuration
public class WebConfigurer implements WebMvcConfigurer {
     
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
     

        //默认地址(可以是页面或后台请求接口)
        registry.addViewController("/").setViewName("forward:/upload.html");
        //设置过滤优先级最高
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    }
}

你可能感兴趣的:(Spring,spring,java,spring,boot,html)