开发者

How to use Struts 2 with JFreeChart?

开发者 https://www.devze.com 2022-12-25 21:39 出处:网络
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.

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/clas开发者_JS百科ses/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?


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>  
0

精彩评论

暂无评论...
验证码 换一张
取 消