Struts2 报出 getOutputStream() has already been called for this response 错误,因为我们设置了返回值,应该设置为空 因为ServletActionContext.getResponse().getOutputStream(); 中Response已经是action 的内置对象了!!
/**
* 套餐统计表柱状图
* @return
*/
public String DrawPackBar(){
DefaultCategoryDataset dp = new DefaultCategoryDataset();
int VIP = packService.countPackbyName("VIP");
int phone = packService.countPackbyName("电话");
int sms = packService.countPackbyName("短信");
int data = packService.countPackbyName("流量");
int erre = packService.countPackbyName("0");
dp.addValue(VIP, "", "VIP套餐");
dp.addValue(phone, "", "电话套餐");
dp.addValue(sms, "", "电话套餐");
dp.addValue(data, "", "流量套餐");
dp.addValue(erre, "", "0套餐");
JFreeChart chart = ChartServer.DrawBar(dp);
try {
ServletOutputStream writer = ServletActionContext.getResponse().getOutputStream();
ChartUtilities.writeChartAsJPEG(writer, chart, 800, 600);
} catch (IOException e) {
e.printStackTrace();
}
return null;//<span style="color:#ff0000;">response 已经是action 的内置对象了</span>
}