简体   繁体   English

Struts 2找不到Eclipse类错误

[英]Struts 2 Eclipse Class Not Found error

Configuring Struts 2 with Eclipse. 使用Eclipse配置Struts 2。 I am having a hard time getting this to work properly. 我很难让它正常工作。 To my understanding, it can find the file, but it can't load the configuration file out of it. 据我了解,它可以找到文件,但是无法从中加载配置文件。 What am I doing wrong? 我究竟做错了什么? I've cleaned the program, all the maven dependencies appear to be there. 我已经清理了程序,所有的Maven依赖项似乎都在那里。 I have another working project and honestly everything looks spot on the same, except that one works, and this one doesn't. 我有另一个工作项目,说实话,所有事情看起来都一样,除了一个可行,而那个没有。

SEVERE: Dispatcher initialization failed
Unable to load configuration. - action - file:/C:/devl/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/sunday/WEB-INF/classes/struts.xml:7:70
    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.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    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 [com.manifestcorp.sunday.SundayAction] not found - action - file:/C:/devl/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/sunday/WEB-INF/classes/struts.xml:7:70
    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

You should not use FilterDispatcher in the new project, this one has been deprecated long time ago. 您不应该在新项目中使用FilterDispatcher ,该项目早已被弃用。 The current struts2 filter class could be configured in the web.xml as 当前的struts2过滤器类可以在web.xml配置为

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
        <param-name>actionPackages</param-name>
        <param-value>com.manifestcorp.sunday</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Note, the init parameter allows you to specify packages to scan for action classes. 注意,init参数允许您指定要扫描操作类的程序包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM