为什么生成图片后,在C:\Users\Jason\AppData\Local\Temp这个文件夹中。      前台JSP中怎么取?在线等。

解决方案 »

  1.   

    生成jfreechart 图片应该是在你的服务器上,为什么会出现在操作系统路径里面?
      

  2.   

    在生成的时候,会有一个图片路径需要设置的。
    JFreeChart chart = null;
    if ("pie".equals(showmode)) {
    // 绘制饼型图
    chart = getChartForPie(type, sql, request);
    } else {
    // 绘制柱型图
    chart = getChartForBar(type, sql, request);
    }
    if (chart != null) {
    chart.getPlot().setDrawingSupplier(new CustomDrawingSupplier());
    myplot(showmode, chart); // 设置各标签的显示样式
    String webName = request.getRealPath("\\publicInfo\\img");
    String picpath = "";
    String mappath = ""; if ("dept".equals(type)) {// 图片路径
    picpath = webName + "/" + showmode + type + ".jpg";
    mappath = webName + "/" + showmode + type + ".map";
    } else if ("date".equals(type)) {// 图片文件路径
    picpath = webName + "/" + showmode + type + i + j + ".jpg";
    mappath = webName + "/" + showmode + type + i + j + ".map";
    } // 热区文件路径
    FileOutputStream plot_fos = new FileOutputStream(picpath);
    PrintWriter map_pw = new PrintWriter(mappath);
    ChartRenderingInfo info = new ChartRenderingInfo(
    new StandardEntityCollection());
    // 生成图片文件
    ChartUtilities.writeChartAsJPEG(plot_fos, 0.8f, chart, width,
    height, info);
    // 生成热区文件
    ChartUtilities.writeImageMap(map_pw, "mymap", info, false);
    plot_fos.close();
    map_pw.close();
    request.setAttribute("path", webName);