如何将 Struts 2 与 JFreeChart 结合使用?

发布于 2024-08-28 03:11:54 字数 1455 浏览 6 评论 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 的依赖项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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑕疵 2024-09-04 03:11:54

您需要在 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>  

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.

<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>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文