myeclipse上面写一个简单的struts2项目action完成跳转 80C

图片说明

图片说明

图片说明

图片说明

图片说明
myeclipse 上面写一个简单的struts2项目 就是完成一个ation的调整就是一个劲报错 求大神指点一二

严重: Dispatcher initialization failed
Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1144)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1878)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
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 [cn.itcast.action.HelloAction] not found - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:420)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 20 more
二月 26, 2018 8:59:05 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter [struts2]
Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1144)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1878)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
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: Unable to load configuration. - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
... 18 more
Caused by: Action class [cn.itcast.action.HelloAction] not found - action - file:/D:/apache-tomcat-8.5.23/webapps/wwww/WEB-INF/classes/struts.xml:6:59
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:420)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:479)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 20 more
非常恐惧 试了很多遍 查了很多网上 的 找不到错误在哪里

7个回答

看样子像是jar包冲突了

manchuprince
manchuprince 抱歉我刚才才上传完成 jar包之前用的是struts2apps例子中的lib里面的jar包 也是这个报错 我又使用了自带的strutsjar包还是这样
2 年多之前 回复

web.xml中没有去加载struts2的核心过滤器

caixianzhi1314
caixianzhi1314 <!-- 引入struts核心过滤器 --> <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>
2 年多之前 回复
caixianzhi1314
caixianzhi1314 回复manchuprince: 在web.xml中引入这一段
2 年多之前 回复
manchuprince
manchuprince 该如何解决呢 请教一下您
2 年多之前 回复

Java代码

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

<constant name="struts.devMode" value="true" />  
<constant name="struts.i18n.encoding" value="UTF-8"/>  
<constant name="struts.objectFactory" value="spring"/>  

<package name="user" namespace="/user" extends="struts-default">  
    <action name="user" class="userAction">  
        <result name="SUCCESS">/list.jsp</result>  
        <result name="ERROR">/error.jsp</result>  
    </action>  
</package>  



在整合ssh时发生以上错误,我main方法测试过spring3.2.2+hibernate4没有问题,数据可以正常新增。但与struts2整合时,发生了错误。

如果在远行 Tomcat 时候报错,
一、要不就是 jar 包 拷少了
二、要不就是 Tomcat 有毛病。ヾ(。 ̄□ ̄)ツ゜゜゜ 重装 Tomcat 吧 。

Struts2 开发环境(2.5.1版本)

所需要的jar包
commons-logging-1.1.3.jar 日志文件,用于通用日志处理
commons-io-2.4.jar Io包
commons-fileupload-1.3.1.jar 文件上传支持的一个类库
commons-lang3-3.4.jar 为java.lang包提供扩展的一个类库
ognl-3.1.8.jar OGNL表达式语言,struts2支持该EL
freemarker-2.3.23.jar 表现层框架,定义了struts2的可视组件主题
struts2-core-2.5.1.jar struts2的核心库
log4j-api-2.5.jar Log4j类库 javassist-3.20.0-GA.jar 分析、编辑、创建Java字节码的类库
xwork-2.0.4.jar webwork的核心库(Struts2的2.5版本和struts2-core-2.5.1.jar合并了
如果是 2.5 以下的版本,可以到 apps 下找到 struts2-blank.war 解压取出里面的 jar

ps:错误是tomcat加载不了 struts 配置文件,可以降低 tomcat 版本试试,或是看下 struts.xml:6:59 是不是有错误

缺少命名空间@Namespace

HelloAction类中加入@hello注解

struts.xml里的 action 这个节点里的类配置错误了,可以删了这个节点重新配置一下!你看下 ctrl+鼠标左键可以点击那个class 的犬类名么

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐