使用Struts 2时未找到操作错误

时间:2017-02-02 07:23:57

标签: java eclipse struts2

02, 2017 4:32:41 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/F:/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/imooc_hibernate_struts/WEB-INF/classes/struts.xml:12:45
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:493)
    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.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4563)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5205)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    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:/F:/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/imooc_hibernate_struts/WEB-INF/classes/struts.xml:12:45
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
    ... 14 more
Caused by: Action class [hello.World] not found - action - file:/F:/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/imooc_hibernate_struts/WEB-INF/classes/struts.xml:12:45
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 17 more

二月 02, 2017 4:32:41 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more Filters failed to start. Full details will be found in the appropriate container log file
二月 02, 2017 4:32:41 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/imooc_hibernate_struts] startup failed due to previous errors
二月 02, 2017 4:32:41 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler [http-nio-8888]
二月 02, 2017 4:32:41 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler [ajp-nio-8009]
二月 02, 2017 4:32:41 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 6400 ms

struts.xml代码

    <?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">
    <struts>
        <!-- 开发模式 - ture -->
        <constant name="struts.devMode" value="true" />
        <!-- 声明包名,并指定命名空间/hello,同时继承于struts-default。 这与我们定义一个class相类似 -->
        <package name="default" namespace="/hello" extends="struts-default">
            <!-- 设置hellostruts Action -->
            <action name="struts" class="hello.World">
                <!-- 设置V层,相对于WebContent的绝对路径 -->
                <result name="success">/WEB-INF/jsp/hellostruts.jsp</result>
            </action>

        </package>
    </struts>

World.java代码

enter image description here

文库

enter image description here

我是初学者。如果我添加class="hello.World",它总是告诉我action hello.World not found,但我确实创建了它,我不知道它是否是版本问题,问题出在哪里。

我没有阅读控制台信息的经验,如果可能的话,请告诉我如何解决问题。这是我得到的错误。

1 个答案:

答案 0 :(得分:0)

检查服务器中是否存在已编译的类,tomcat应该在webapps/.../WEB-INF/classes/hello/World.class中。根据您配置Eclipse构建器的方式,每次进行更改时都应更新此文件。如果编译的文件没问题,我猜这个类路径存在一些问题。