自定义异常视图解析器的演示:
@Configuration
public class WebConfig implements WebMvcConfigurer
{
@Override
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(new LoginHanlderIntercept()).
//拦截任意多层路径下的所有请求,某些请求不进行拦截
addPathPatterns("/**").
excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**","/js/**");
}
}
/**
* 全面接管springmvc时,定义静态资源行为
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
/**
* 访问 /aa/** 所有请求都去 classpath:/static/ 下面进行匹配
*/
registry.addResourceHandler("/aa/**")
.addResourceLocations("classpath:/static/");
}
场景starter - xxxxAutoConfiguration - 导入xxx组件 - 绑定xxxProperties – 绑定配置文件项