我正在使用Struts2。我需要在網頁中顯示JFreeChart。任何機構能幫助我嗎?使用Struts2在網頁中顯示JFreeChart
編輯:它以二進制格式顯示。
public String execute() throws Exception {
System.out.println("Refresh bar Chart");
response.setContentType("image/png");
OutputStream outstream = response.getOutputStream();
try {
JFreeChart chart = getChartViewer();
ChartUtilities.writeChartAsPNG(outstream, chart, 500, 300);
System.out.println("Created bar Chart");
return SUCCESS;
} finally {
outstream.close();
response.flushBuffer();
}
}
我重新格式化您的評論的代碼;如果不正確,則還原。 – trashgod 2010-03-30 23:40:21