2

是否有action-default与 Struts2 相关的软件包?

我不确定它来自哪个 jar(struts-core 或插件),但它已经存在struts.xml了很多年。我们使用了 struts-core-2.1.8。

我将 struts 版本更新到 2.3.8 并且 struts 开始抱怨,

SEVERE: Exception starting filter struts2-prepare
Unable to load configuration. - [unknown location]
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:483)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.init(StrutsPrepareFilter.java:50)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4656)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5312)
    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$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: Unable to load configuration. - [unknown location]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
    ... 15 more
Caused by: Parent package is not defined: action-default - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:660)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:508)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:290)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:239)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 17 more

我找不到任何关于action-default包装的参考资料。任何人都可以帮我弄清楚action-default包中可用的内容以及 Struts 2.3.8 中的替代品。

编辑:

发不完整struts.xml,太长了 包装声明如下,

<package name="default" extends="struts-default,jfreechart-default,json-default,action-default">

使用的 Struts 相关 jar 的工件 ID:

  1. struts2-core 2.1.8
  2. struts2-convention-plugin 2.1.8
  3. struts2-spring-plugin 2.1.8
  4. struts2gwtplugin 0.2.1
  5. struts2-jfreechart-插件 2.1.6
  6. struts2-jquery-插件 3.5.0
  7. struts2-json-插件 2.1.8.1

有了上面提到的所有 jars,struts 并没有抱怨“action-default”包。

将以下 jar 更新到 2.3.8 版本后,struts 开始抱怨缺少包,

  1. struts2-core 2.3.8
  2. struts2-convention-plugin 2.3.8
  3. struts2-spring-plugin 2.3.8
  4. struts2-json-插件 2.3.8
4

2 回答 2

1

Struts 默认配置中没有这样action-default的包名,包名是struts-default. 更改您的包扩展的包的名称。

于 2013-10-01T14:18:13.900 回答
0

我也遇到了同样的问题,但使用下面列出的 JAR 可以正常工作,

commons-fileupload-1.3.2.jar commons-io-2.2.jar commons-lang3-3.2.jar commons-logging-1.1.3.jar freemarker-2.3.22.jar javassist-3.11.0.GA.jar ognl- 3.0.19.jar struts2-core-2.3.30.jar struts2-json-plugin-2.3.30.jar xwork-core-2.3.30.jar

我的 STRUTS.XML 看起来像,

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="default" extends="json-default">
    <action name="angularAction" class="com.action.AngularAction">
        <result type="json">
          <param name="root">personData</param>
          <param name="excludeNullProperties">true</param>
          <param name="noCache">true</param>
        </result>
    </action>
</package>
</struts>
  • 问候,SUBODH K SINGH
于 2016-10-05T15:18:09.210 回答