您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> 刚学struts2,总是报错Caused by Action class not found

刚学struts2,总是报错Caused by Action class not found

来源:网络整理     时间:2016/5/7 5:21:55     关键词:not found,struts2

关于网友提出的“刚学struts2,总是报错Caused by Action class not found”问题疑问,本网通过在网上对“刚学struts2,总是报错Caused by Action class not found”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:刚学struts2,总是报错Caused by Action class not found
描述:

小弟初学struts2,按书上写了个程序但是运行总是报错。。Caused by Action class not found,但是我按着ctrl点击struts.xml中zhang.LoginAction也能定位到LoginAction类,研究了一天还是没有找到原因,特来求教404 not found,peak not found,not found,book not found,not found什么意思,404 not found修复,网页显示not found,file not found,404 not found解决,command not found,device not found,404 not found图片,not found怎么修复,page not found,404not found怎么
三月 01, 2014 11:34:32 下午 org.apache.struts2.dispatcher.Dispatcher error
SEVERE: Dispatcher initialization failed
Unable to load configuration. - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsTestDemo/WEB-INF/classes/struts.xml:12:50
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Action class [zhang.LoginAction] not found - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsTestDemo/WEB-INF/classes/struts.xml:12:50
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:482)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:426)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:552)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:258)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 15 more
-------------------------------------------------
struts.xml

    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
    "http://struts.apache.org/dtds/struts-2.0.dtd">  









/login.jsp
/error.jsp
/welcome.jsp        



--------------------------------
LoginAction.java
package zhang;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport
{
private String username;
private String password;
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
{
if (getUsername().equals("scott")
&& getPassword().equals("tiger") )
{
ActionContext.getContext().getSession().put("user" , getUsername());
return SUCCESS;
}
else
{
return ERROR;
}
}
}


解决方案1:

1.检查action的name值和url中的大小写是否相同。
2.检查action中的class的路径名和你写的类名的大小写。

解决方案2:

找不到类一般是jar包有问题或者没有构建路径。

解决方案3:

一个是jar包的问题,还有,是不是你的action没有配置action中方法啊?
另外,提供几个思路吧。
1、检查访问URL的大小写
2、你返回的string与result中定义的也不一样啊

解决方案4:

可能是多导入没用的包了,导致jar包冲突,
struts 基本的导入这几个就够用了,你看看是不是有这以外的其他没用jar包
commons-fileupload-1.2.2
commons-io-2.0.1
commons-lang-2.4
commons-logging-1.1.1
freemarker-2.3.19
javassist-3.11.0.GA
ognl-3.0.5
struts2-core-2.3.4.1
xwork-core-2.3.4.1

解决方案5:

clean 一下项目,重新部署看看

解决方案6:

正常的话你的struts配置文件是可以找到action的,原因可能是楼上说的


以上介绍了“刚学struts2,总是报错Caused by Action class not found”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/952958.html

相关图片

相关文章