日期:2014-05-17  浏览次数:20733 次

Caused by: Action class [com.test.action.LoginAction] not found
新手学struts时报了这个错误:Caused by: Action class [com.test.action.LoginAction] not found    但是这个类肯定有啊,如下:
package com.test.action;  
  
import com.opensymphony.xwork2.Action;
public class LoginAction implements Action

    //对应表单上的  
    private String username;  
    private String password;  
    //getter和setter方法   就是根据这里的方法名来匹配客户端的信息  
    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 execute() throws Exception  
     {  
           return "success";  
     }  
}  
而且那些包也都导入了(commons-fileupload-1.2.2.jar  commons-io-2.0.1.jar  commons-lang3-3.1.jar    commons-logging-1.1.1.jar freemarker-2.3.19.jar javassist-3.11.0.GA.jar ognl-3.0.6.jar   struts2-core-2.3.8.jar xwork-core-2.3.8.jar ),为什么呢?

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="default" extends="struts-default">  
   <action name="login" class="com.test.action.LoginAction">  
    <!-- result没有名字是默认的success -->  
    <result name="success">/result.jsp</result>  
   </action>  
   </package>  
</struts> 
struts2

------解决方案--------------------
看看LoginAction的class文件是否是最新的
------解决方案--------------------
Caused by: Action class [com.test.action.LoginAction] not found    
不是说java文件存在就没问题,主要是看编译后的class文件是否存在
------解决方案--------------------
可能是你运行时的jdkg与开发时的jdk不是同一个版本的。