chenyang_494 2014-05-19 10:29
浏览 776

使用JFreeChart产生图片 后台报错!!!!在线等解答

因为框架不让修改web.xml文件,故让src等于后台路径,跪求好的实现方法!!!!还有就是后台报错:java.lang.IllegalStateException: getOutputStream() has already been called for this response,虽然搜了网上解决办法,说是jsp使用对象会调用response.getWriter(),因为这个方法是和response.getOutputStream()相冲突的,所以才会报此错误,但是是我这部分代码的实现是放在后台实现应该怎么修改呢??

详细代码展示如下:
页面部分:

js部分:
var para = "&width=" + 500 + "&height=" + 300 + "&dataString="+dataset;
var jspUrl = '<%=request.getContextPath()%>/ChartAction?action=createPieChart'+para;
document.getElementById("dayId").src=jspUrl;
后台代码:

OutputStream out = response.getOutputStream();
try{
DefaultPieDataset data = new DefaultPieDataset();
data.setValue(ruleName,ruleName);
JFreeChart chart = ChartFactory.createPieChart3D("规则分布", data, true,true, false);
chart.setBackgroundPaint(Color.white);
chart.setBorderVisible(false);
//获得3D的水晶饼图对象
PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot();
//设置开始角度
pieplot3d.setStartAngle(100D);
//设置方向为”顺时针方向“
pieplot3d.setDirection(Rotation.CLOCKWISE);
//设置透明度,0.5F为半透明,1为不透明,0为全透明
pieplot3d.setForegroundAlpha(1);
pieplot3d.setNoDataMessage("No date");
ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart,width, height);
}catch (Exception e) {
log.error("..................");
}finally {
out.close();
}

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog