saveChartAsJPEG public static java.lang.String saveChartAsJPEG(JFreeChart chart, int width, int height, ChartRenderingInfo info, javax.servlet.http.HttpSession session) throws java.io.IOExceptionSaves the chart as a JPEG format file in the temporary directory and populates the ChartRenderingInfo object which can be used to generate an HTML image map. Parameters: chart - the chart to be saved (null not permitted). width - the width of the chart height - the height of the chart info - the ChartRenderingInfo object to be populated session - the HttpSession of the client Returns: the filename of the chart saved in the temporary directory Throws: java.io.IOException - if there is a problem saving the file.
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
这样才可以,我记得在配置时还要注意servlet的顺序
public static java.lang.String saveChartAsJPEG(JFreeChart chart,
int width,
int height,
ChartRenderingInfo info,
javax.servlet.http.HttpSession session)
throws java.io.IOExceptionSaves the chart as a JPEG format file in the temporary directory and populates the ChartRenderingInfo object which can be used to generate an HTML image map. Parameters:
chart - the chart to be saved (null not permitted).
width - the width of the chart
height - the height of the chart
info - the ChartRenderingInfo object to be populated
session - the HttpSession of the client
Returns:
the filename of the chart saved in the temporary directory
Throws:
java.io.IOException - if there is a problem saving the file.
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"><web-app>
<display-name>QM</display-name>
<servlet>
<servlet-name>webwork</servlet-name>
<servlet-class>com.opensymphony.webwork.dispatcher.ServletDispatcher</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webwork</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping> <servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>webwork</taglib-uri>
<taglib-location>/WEB-INF/lib/webwork-2.1.jar</taglib-location>
</taglib> <taglib>
<taglib-uri>http://displaytag.sourceforge.net/</taglib-uri>
<taglib-location>/WEB-INF/displaytag-11.tld</taglib-location>
</taglib>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list> <resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>DS_SOP</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>