【问题标题】:How can i store image in my project hosted in openshift?如何将图像存储在我托管在 openshift 中的项目中?
【发布时间】:2015-05-25 03:21:51
【问题描述】:

我正在尝试创建图表并将图表保存在图像文件夹中。它在本地运行良好,但是当我在 openshift online 中托管它时它不起作用。

String root = getServletContext().getRealPath("/");
   File savedFile = new File(root+"\\images\\piechart.jpg");
   ChartUtilities.saveChartAsJPEG(savedFile, piechart, 700, 400); 

root 给出 null 所以保存不起作用...请帮助存储图像。

【问题讨论】:

  • 你可以writeChartAsJPEG() 代替吗?
  • 谢谢.....在进行此更改后现在可以正常工作,即使用 java servlet 的 writeChartAsJPEG()... :) 快乐编码

标签: jsp openshift jfreechart


【解决方案1】:

您可以使用ChartUtilities.writeChartAs… 的变体之一将图像写入servlet 的OutputStream,而不是将图表保存为本地文件夹中的图像。

ChartUtilities.writeChartAsJPEG(response.getOutputStream(), …);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), …);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-18
    • 2021-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多