struts中过滤器配置问题
我想让所有的MyServlet请求都经过struts2Filter过滤器,这样写会报如下错?该如何解决?
2010-11-25 09:31:53 [http-8088-2] WARN [org.apache.struts2.dispatcher.Dispatcher-49] - Could not find action or result
There is no Action mapped for namespace / and action name MyServlet. - [unknown location]
---------------------------------------
<filter>
<filter-name>struts2Filter</filter-name>
<filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>/MyServlet</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<servlet>
<display-name>MyServlet</display-name>
<servlet-name>MyServlet</servlet-name>
<servlet-class>
xxx.MyServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
------解决方案--------------------There is no Action mapped for namespace / and action name MyServlet. - [unknown location
你这个过滤器要放在struts2的那个过滤器后面才行
其次 你的struts2的拦截 不要设置成 /* ,你试试拦截.action 看看.
------解决方案--------------------试着看下classes目录下有没有struts.xml文件
------解决方案--------------------<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
这个url-pattern标签里面写成/*试试