qq_26104055
qq_26104055
采纳率100%
2017-02-13 14:49 浏览 1.1k
已采纳

Strus2 Unable to load configuration.

程序启动的时候报错:
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/home/yinyutai/self/app/Tomcat/apache-tomcat-7.0.75/webapps/day24_struts1/WEB-INF/classes/struts.xml:7:85
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:502)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
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:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load configuration. - action - file:/home/yinyutai/self/app/Tomcat/apache-tomcat-7.0.75/webapps/day24_struts1/WEB-INF/classes/struts.xml:7:85
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
... 14 more
Caused by: Action class [com.itheima.web.action.HelloAction] not found - action - file:/home/yinyutai/self/app/Tomcat/apache-tomcat-7.0.75/webapps/day24_struts1/WEB-INF/classes/struts.xml:7:85
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:250)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 16 more
但是看了提示的那个位置,写的是:
  那个位置是method="sayHello" 没发现有什么错误!
这是引用的jar文件
HelloAction.java:
package com.itheima.web.action;
/**

  • Struts2入门案例
  • @author root * / public class HelloAction { /*
    • 在动作类中制定的动作方法
    • 动作方法的书写要求:
    • 1.都是public的
    • 2.返回值必须是String
    • 3.必须没有参数
    • @return */ public String sayHello() { System.out.println("sayHello,方法执行了!"); return "success"; }

}
web.xml:

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


day24_struts1
<!-- 配置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>


index.jsp

请大神,给看下,这是一个Struts2的一个小例子但是没有启动起来不知到错误出在哪里,谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答 默认 最新

相关推荐