日期:2014-05-20  浏览次数:20606 次

structs2配置后运行总是有问题
structs2.18   +   Tomcat6.0.35,没用eclipse

web.xml:
<?xml   version= "1.0 "   encoding= "utf-8 "?>
<web-app   xmlns= "http://java.sun.com/xml/ns/j2ee "   xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "   version= "2.5 "   xsi:schemaLocation= "http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
    <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>
    <!--   ...   -->
</web-app>

HelloWorld:
package   com;
public   class   HelloWorld   {
        public   String   execute()   throws   Exception     {
                return   "success ";
        }

}


structs.xml:
<?xml   version= "1.0 "   encoding= "UTF-8 "   ?>
<!DOCTYPE   struts   PUBLIC  
"-//Apache   Software   Foundation//DTD   Struts   Configuration   2.1//EN "
"http://struts.apache.org/dtds/struts-2.1.dtd ">
<struts>
    <package   name= "pkg "   namespace= "/hello "   extends= "struts-default ">
        <action   name= "HelloWorld "   class= "com.HelloWorld ">
            <result   name= "error "> /error.jsp </result>
            <result   name= "success "> /index.jsp </result>
        </action>
    </package>
</struts>

启动Tomcat时有这样一条信息:Unable   to   locate   configuration   files   of   the   name   struts.xml,   skipping
我怀疑是它的问题,但是classes文件夹下有structs.xml文件
http://localhost:8080/test/hello/HelloWorld.action
      报错404     There   is   no   Action   mapped   for   action   name   HelloWorld

我为这个问题已经整了2天了,不但没解决,还弄出了许多别的问题,哪位大侠帮我看下吧,我实在是没办法了。

------解决方案--------------------
3.. Struts2默认的配置文件为struts.xml ,你的怎么是structs.xml呢