jfreechart显示不出图片

纯纯love 发布于 2014/04/20 11:00
阅读 700
收藏 0
xml配置如下
<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>

jsp内容如下
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="org.jfree.chart.ChartFactory,
org.jfree.chart.JFreeChart,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.DefaultCategoryDataset"%>
<%
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(610, "Guangzhou", "Pig");
dataset.addValue(220, "Guangzhou", "Beef");
dataset.addValue(530, "Guangzhou", "Chicken");
dataset.addValue(340, "Guangzhou", "Fish");
JFreeChart chart = ChartFactory.createBarChart3D("肉类销量统计图",
"type",
"amount",
dataset,
PlotOrientation.VERTICAL,
false,
false,
false);
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session);
String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;
%>
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>">
在浏览器访问得到一个x,但是在tomcattemp文件夹里面有表

求大神解惑
加载中
0
起色
起色

首先确认一下有没有该路径下是不是真有图片,其次,jfreechart不用真生成图片吧,返回一个图片流就可以了

0
纯纯love
纯纯love

DisplayChart文件夹,但是没有图片在里面


返回顶部
顶部