0

首先,我去了这里(http://code.google.com/p/struts2-examples/downloads/list并下载了 Hello_World_Struts2_Mvn.zip)并运行了该示例。

之后,我去了这里(http://struts.apache.org/2.x/docs/jfreechart-plugin.html),我添加了 commons-lang-2.5.jarjcommon-1.0.16.jar的依赖项和jfreechart-1.0.13.jar我修改了从 code.google.com 下载的示例以查看JFreeChart是如何工作的,但我收到此错误:

Unable to load configuration. - action - file:/C:/.../untitled_war_exploded/WEB-INF/classes/struts.xml:34:67

Caused by: Error building results for action createChart in namespace  - action - file:/C:/.../out/artifacts/untitled_war_exploded/WEB-INF/classes/struts.xml:34:67

Caused by: There is no result type defined for type 'chart' mapped with name 'success'.  Did you mean 'chart'? - result - file:/C:/.../out/artifacts/untitled_war_exploded/WEB-INF/classes/struts.xml:36:49

struts.xml 的第 36 行是这段代码(来自 struts2 网站的代码):

<action name="viewModerationChart" class="myapp.actions.ViewModerationChartAction">
  <result name="success" type="chart">
    <param name="width">400</param>
    <param name="height">300</param> 
  </result>
</action>

我做错了什么?

4

1 回答 1

0

您需要在 Struts.xml 中以不同的方式定义与图表相关的操作映射。使用 Jfreechart 相关操作更改项目的 struts.xml 并将其定义在单独的包中。例如。

<package name="struts2" extends="jfreechart-default">  
<action name="viewModerationChart" class="myapp.actions.ViewModerationChartAction">
  <result name="success" type="chart">
    <param name="width">400</param>
    <param name="height">300</param> 
  </result>
</action>
</package>  
于 2010-09-10T11:24:27.183 回答