当前位置: 代码迷 >> Java相关 >> Struts2整理-错误以及处理
  详细解决方案

Struts2整理-错误以及处理

热度:55   发布时间:2016-04-22 19:22:49.0
Struts2整理-----异常以及处理

There is no result type defined for type 'chart' mapped with name 'success'

在struts2与JFreeChart整合使用时,直接配置如下action

<!-- 图表输出action -->  <action name="ChartOutputAction" class="chartOutputAction">   <result name="success" type="chart">    <param name="height">300</param>    <param name="width">400</param>   </result>  </action>

出现这样的异常:

Caused by: There is no result type defined for type 'chart' mapped with name 'success'.  Did you mean 'chart'? - result - file:/D:/apache-tomcat-7.0.35/webapps/DAQ/WEB-INF/classes/struts.xml:114:40    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:721)    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:435)    ... 21 more

解决:

在struts2默认的struts-default.xml中,并没有包含chart的result-type,它是插件的形式使用的。

PS:关于result-type详细介绍 http://blog.csdn.net/liyunyun6/article/details/9730505

项目中导入struts2-jfreechart-plugin-2.3.15.1.jar,同时在struts.xml里面增加一个chart的result-type。

     <result-types>            <result-type name="chart"                class="org.apache.struts2.dispatcher.ChartResult" />        </result-types>        <!-- 图表输出action -->        <action name="ChartOutputAction" class="chartOutputAction">            <result name="success" type="chart">                <param name="height">300</param>                <param name="width">400</param>            </result>        </action>

 

  相关解决方案