2010-04-08 74 views
0

首先,我去了這裏(http://code.google.com/p/struts2-examples/downloads/list和我下載了Hello_World_Struts2_Mvn.zip),我運行了這個例子。如何在JFreeChart中使用Struts 2?

在那之後,我就在這裏(http://struts.apache.org/2.x/docs/jfreechart-plugin.html),我想補充的依賴關係公地郎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> 

我做錯了什麼?

回答

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

有什麼辦法可以在不使用struts-jfreechart插件的情況下在struts2中生成jfreechart – CodeHunter 2013-02-21 04:43:45