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

struts2.18怎么启动不了呢?Unable to load configuration. - action
tomcat6.0.14,struts2.1.81,简单的一个例子居然就不能成功,郁闷啊,已导入的jar包有7个,分别是:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
struts2-core-2.1.8.1.jar
xwork-core-2.1.6.jar

我的web.xml如下:
Java code

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>/*</url-pattern>
    </filter-mapping>
    
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    
</web-app>



src下的struts.xml如下:
Java code

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="reg" extends="struts-default">
        <action name="register" class="com.ac.action.RegisterAction" >
            <result type="success">/succ.jsp</result>
            <result type="failure">/fail.jsp</result>
        </action>
    </package>
</struts>



RegisterAction.java如下:
Java code

package com.ac.action;

import com.opensymphony.xwork2.ActionSupport;

public class RegisterAction extends ActionSupport {

    private String username;
    private String password;
    private String password2;
    
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getPassword2() {
        return password2;
    }
    public void setPassword2(String password2) {
        this.password2 = password2;
    }
    
    @Override
    public String execute() throws Exception {
        return "success";
        
    }
}





conf下的sever.xml如下:
Java code

.
.
<Context path="/reg" docBase="E:\workspace\aaa\WebRoot" reloadable="true"> </Context>
.
.


reg.jsp如下:
Java code

  <body>
    <form action="register.action" method="post">
      <table border="0">
        <tr>
          <td>用户名:</td>
          <td><input type="text" name="username" /></td>
        </tr>
        <tr>
          <td>密    码:</td>
          <td><input type="password" name="password" /></td>
        </tr>
        <tr>
          <td>重复密码:</td>
          <td><input type="password" name="password2" /></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><input type="submit" value="注册"   /></td>
        </tr>
      </table>
    </form>
  </body>