kevliudm

spring boot项目一般通过Application启动,且不需要配置web.xml,所以设置默认访问页面可以通过以下方法实现,比如增加默认DefaultView类,代码如下:

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 DefaultView extends WebMvcConfigurerAdapter {
	
    @Override
    public void addViewControllers(ViewControllerRegistry reg) {
    	reg.addViewController("/").setViewName("login");//默认访问页面
        reg.setOrder(Ordered.HIGHEST_PRECEDENCE);//最先执行过滤
        super.addViewControllers(reg);
    }
}

分类:

技术点:

相关文章:

  • 2021-04-15
  • 2021-11-09
  • 2021-12-21
  • 2021-07-28
  • 2021-05-07
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2021-11-20
  • 2021-10-01
  • 2021-12-04
  • 2022-02-08
  • 2021-08-26
  • 2021-11-27
相关资源
相似解决方案