spring mvc 拦截器 拦截不到请求
拦截器继承和实现的类如下:
public class LoginInterceptor extends HandlerInterceptorAdapter
implements InitializingBean
并且实现了请求 前后的3个方法
web.xml 配置:
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
springmvc-servlet.xml 配置:
<bean id="loginInterceptor" class="com.luse.web.interceptor.LoginInterceptor"/>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<!-- <property name="mappings"> -->
<!-- <props> -->
<!-- <prop key="/user/**">userController</prop> -->
<!-- </props> -->
<!-- </property> -->
<property name="interceptors">
<list>
<ref bean="loginInterceptor" />
</list>
</property>
</bean>
在这里不配置mappings 就是拦截所有请求, 现在一个也没拦截到
------解决方案--------------------
加了这个没
<!-- 配置spring的filter -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>