<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<mvc:exclude-mapping path="/login"/>
<mvc:exclude-mapping path="/index"/>
<bean class="com.xl.interceptor.MyInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
xml配置是这样的。
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if(null != request.getSession().getAttribute(Constant.IDENTIFICATION)) {
return true;
}
response.sendRedirect(request.getContextPath() + "/login");
return false;
}
/login 貌似还是被拦截了,chrome显示循环重定向了
------解决思路----------------------
你mapping "/**"的时候估计就拦截了
看看吧
------解决思路----------------------
<mvc:mapping?path="/**"/>改成?<mvc:mapping?path="/"/>试试
------解决思路----------------------
mvc-config-interceptors
15.12.2 mvc:interceptors
This tag allows you to register custom HandlerInterceptors or WebRequestInterceptors that should be applied to all HandlerMapping beans. You can also restrict the URL paths specifc interceptors apply to.
An example of registering an interceptor applied to all URL paths:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
An example of registering an interceptor limited to a specific URL path:
<mvc:interceptors>
<mvc:interceptor>
<mapping path="/secure/*"/>
<bean class="org.example.SecurityInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
得根据你的路径看,
