@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("/**");
}
}

 

posted @ 2019-11-26 11:16  MartinEDM  阅读(167)  评论(0编辑  收藏  举报