当前位置: 代码迷 >> Ajax >> There is no Action 地图ped for namespace / and action name AjaxServlet. - [unknow
  详细解决方案

There is no Action 地图ped for namespace / and action name AjaxServlet. - [unknow

热度:581   发布时间:2012-08-24 10:00:20.0
There is no Action mapped for namespace / and action name AjaxServlet. - [unknow

There is no Action mapped for namespace / and action name AjaxServlet. - [unknown location]

?

原因:web.xml中配置struts拦截为/*,AjaxServlet被拦截掉

<filter>
? ?<filter-name>struts2</filter-name>
? ?<filter-class>
? ?org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
? ?</filter-class>
? </filter>
? <filter-mapping>
? ?<filter-name>struts2</filter-name>
? ?<url-pattern>/*</url-pattern>
? </filter-mapping>

?

?<servlet>
??? <description></description>
??? <display-name>AjaxServlet</display-name>
??? <servlet-name>AjaxServlet</servlet-name>
??? <servlet-class>org.CollegePro.ssh.web.servlet.AjaxServlet</servlet-class>
? </servlet>
? <servlet-mapping>
??? <servlet-name>AjaxServlet</servlet-name>
??? <url-pattern>/AjaxServlet</url-pattern>
? </servlet-mapping>

?

解决办法:修改struts的过滤器设置,如下。只对.aciton结尾的请求和.jsp结尾请求过滤,这样就可以保证Ajax的过滤器能正常使用。

? <filter>
? ?<filter-name>struts2</filter-name>
? ?<filter-class>
? ?org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
? ?</filter-class>
? </filter>
? <filter-mapping>
? ?<filter-name>struts2</filter-name>
? ?<url-pattern>*.action</url-pattern>
? </filter-mapping>
?? <filter-mapping>
? ?<filter-name>struts2</filter-name>
? ?<url-pattern>*.jsp</url-pattern>
? </filter-mapping>

  相关解决方案