如何将 Struts 2 与 JFreeChart 结合使用?
首先,我去了这里( 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 的依赖项strong> 和 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>
我做错了什么?
Firstly, I went here ( http://code.google.com/p/struts2-examples/downloads/list and I downloaded Hello_World_Struts2_Mvn.zip) and I run that example.
After that, I went here (http://struts.apache.org/2.x/docs/jfreechart-plugin.html), I add the dependencies for commons-lang-2.5.jar, jcommon-1.0.16.jar and jfreechart-1.0.13.jar and I modify the example downloaded from code.google.com to see how JFreeChart is working, but I receive this error:
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
At the line 36 in struts.xml is the this code (the code from struts2 website):
<action name="viewModerationChart" class="myapp.actions.ViewModerationChartAction">
<result name="success" type="chart">
<param name="width">400</param>
<param name="height">300</param>
</result>
</action>
What I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 Struts.xml 中以不同方式定义与图表相关的操作映射。使用 Jfreechart 相关操作更改项目的 struts.xml 并将其定义在单独的包中。
例如。
You need to define Action mappings related to chart differently in Struts.xml.Change your project's struts.xml with Jfreechart related actions and define it in separate package.
For eg.