web.xml文件中的配置文件如下:
<filter>
<filter-name>userSession</filter-name>
<filter-class>
cn.com.dmax.tools.UserSessionFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>userSession</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping><url-pattern>*.action</url-pattern>我配置的是*.action 但是但是貌似所有的.action请求都进入不到过滤器里面。这个该如何配置?我想对所有的.action请求检查用户是否登陆?如果我把*.action换成/*的,断点的时候就能进入到过滤器里面,然后我将所有的请求路径都打印在控制台,问题是也没有.action请求,打印出来的都是.jsp、.css、.js请求。求解
<filter>
<filter-name>userSession</filter-name>
<filter-class>
cn.com.dmax.tools.UserSessionFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>userSession</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping><url-pattern>*.action</url-pattern>我配置的是*.action 但是但是貌似所有的.action请求都进入不到过滤器里面。这个该如何配置?我想对所有的.action请求检查用户是否登陆?如果我把*.action换成/*的,断点的时候就能进入到过滤器里面,然后我将所有的请求路径都打印在控制台,问题是也没有.action请求,打印出来的都是.jsp、.css、.js请求。求解
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-data.xml,
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<!-- 中文乱码过滤处理 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>
cn.com.dmax.tools.SetCharacterEncodingFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 用户是否登陆 -->
<filter>
<filter-name>userSession</filter-name>
<filter-class>
cn.com.dmax.tools.UserSessionFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>userSession</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
</web-app>
<filter>
<filter-name>userSession</filter-name>
<filter-class>
cn.com.dmax.tools.UserSessionFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>userSession</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping> <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
String requestURL=request.getRequestURI();
输去,没有action的东西吗?
要么你重写struts的过滤器,把你的功能加上