简单的测试登录程序,显示错误了我的web.xml是这样写的:<?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 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但是我加了

解决方案 »

  1.   

    少了一个io的jiar包,导进来就可以了
      

  2.   

    同楼上,commons-io的jar包加了么
      

  3.   

    commons-io.XXX.jar这个在tomcat项目目录的lib里有吗?没有加上试试
      

  4.   

    struts基本导包如下:
    打开struts下的apps  里面一个struts2-blank.war
    用压缩文件解压  然后把里面的jar包复制到你的项目下就可以了
    基本应用这些包足够了  如果有特殊应用可以根据tomcat的报错提示继续导包
      

  5.   

     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
     </filter>  楼主写的已经过时了!   
      

  6.   


    同意!试试,你那个xml配置是过时的!