首先,我去了这里(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.jar , jcommon-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>
我做错了什么?
答案 0 :(得分:0)
您需要在Struts.xml中以不同方式定义与图表相关的Action映射。使用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>