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

struts2.2.3.1配置问题
简单的测试登录程序,显示错误了我的web.xml是这样写的:
XML 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">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <filter>
  <filter-name>struts</filter-name>
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
  <filter-name>struts</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>



struts.xml这样写的
XML 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="struts2" namespace="/" extends="struts-default">
        <action name="login" class="LoginAction">
            <result name="success">/success.jsp</result>
            <result name="fail" type="redirect">/login.jsp</result>
        </action>
    </package>
</struts>

[code=Java]

public class LoginAction {
    private String name;
    private String psd;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPsd() {
        return psd;
    }
    public void setPsd(String psd) {
        this.psd = psd;
    }
    public String execute() {
        if(name.equals("dai")&&psd.equals("dai")) {
            return "success";
        }
        return "fail";
    }
}


login.jsp
[code=Java]

public class LoginAction {
    private String name;
    private String psd;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPsd() {
        return psd;
    }
    public void setPsd(String psd) {
        this.psd = psd;
    }
    public String execute() {
        if(name.equals("dai")&&psd.equals("dai")) {
            return "success";
        }
        return "fail";
    }
}


[/code]
[/code]

然后
报错如下:
警告: Could not create JarEntryRevision for [jar:file:/D:/apache-tomcat-6.0.30/webapps/StrutsDemo2/WEB-INF/lib/struts2-core-2.2.3.1.jar]!
java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

但是我加了

------解决方案--------------------
应该是导的包不够,楼主在按照提示好好找找。