每个请求是否有一个新的Spring HandlerInterceptors实例?
我在Spring中有一个拦截器,其中包含一个类字段。
public class MyInterceptor extends HandlerInterceptorAdapter {
Private boolean state = false;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
state = true;
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
if (state == true) {
System.out.println("Success");
}
}
如果使用这个拦截器,它是否总是会打印“Success”?(无论同时有多少线程在执行?)