一、两种网上的方法,本人是想在说s2sh项目中加入xheditor(在线编辑器)功能,通过下面的两种方法发现不是action有问题,就是servlet有问题,因此不行。
但是毕竟这两种方法简单好理解,不放先试一下,说不定你的项目能行。
解决Could notfind action or result There is noAction mapped for namespace / and action nameChk有两种偏门的办法:1、修改servlet的配置文件的<url-pattern>,struts2的filter中<url-pattern>不变2、修改struts2的filter中<url-pattern>,servlet中的<url-pattern>不变
原配置文件:
<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>
<servlet-name>Chk</servlet-name>
<servlet-class>com.thdx.action.Chk</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Chk</servlet-name>
<url-pattern>/Chk</url-pattern>
</servlet-mapping>
修改后
.........
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping> //servlet中的<url-pattern>不变
或
.....
<servlet-mapping>
<servlet-name>Chk</servlet-name>
<url-pattern>/Chk.servlet</url-pattern>//点后面随便怎么写
</servlet-mapping> //struts2的filter中<url-pattern>不变
二、一种保证有效的方法
}
怕大家还是配置错误,给一个web.xml的配置实例。
<filter>
<filter-name>redisp</filter-name>
<filter-class>com.xheditor.servlet.ReDispatcherFilter</filter-class>
<init-param>
<param-name>includeServlets</param-name>
<param-value>UploadFileServlet</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>redisp</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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>
<servlet-name>XhEditor</servlet-name>
<servlet-class>com.xheditor.servlet.UploadFileServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XhEditor</servlet-name>
<url-pattern>/UploadFileServlet</url-pattern>
</servlet-mapping>