我在config里添加了一个@Configuration的配置类,是为了给,定时任务添加一个Executor,但是加了之后,拦截器就失效了。任何请求都不走拦截器了。以下是我的代码
@Configuration
public class ApplicationContext extends WebMvcConfigurationSupport {
@Bean
public TaskScheduler taskScheduler(){
return new ConcurrentTaskScheduler();
}
}
这个是我的拦截器
public class ContextInterceptor implements HandlerInterceptor {
public static ResourceBundle bundle;
static {
bundle = ResourceBundle.getBundle("application");
}
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
String staticPath = bundle.getString("sys.static.path");
httpServletRequest.setAttribute("staticUrl",staticPath);
String basePath = bundle.getString("sys.base.path");
httpServletRequest.setAttribute("baseUrl",basePath);
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
求大神指教
配置类不要继承 WebMvcConfigurationSupport