@EnableWebMvc
禁用spring 的默认配置 手动配置
@EnableWebMvc
public class TestAppConfig implements WebMvcConfigurer {
//视图解析器
public void configureViewResolvers(ViewResolverRegistry registry) {
//我们想用jsp解析器 ,默认所有页面都从/WEB-INF/pages
registry.jsp("/WEB-INF/pages/","jsp");
}
//静态资源的访问
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
//拦截器
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TestInterceptors()).addPathPatterns("/**");
}
}