[color=darkred]Action:
public ActionForward shopprint(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String filename="";
PrintWriter out = null;
String month ="";
String shopnum= request.getParameter("shopnum");
month ="2010-02";
request.setAttribute("shopnum", shopnum);
try{
JFreeChart chart=mutiTimeLineChart.createChart(mutiTimeLineChart.getDataset(month, shopnum));
chart.setBackgroundPaint(Color.YELLOW);
ChartRenderingInfo info=new ChartRenderingInfo(new StandardEntityCollection());
try {
HttpSession session = request.getSession();
filename=ServletUtilities.saveChartAsPNG(chart, 900, 400,info, session);
request.setAttribute("filename", filename);
} catch (IOException e) {
e.printStackTrace();
}
try {
ChartUtilities.writeImageMap(out, filename, info, false);
} catch (IOException e) {
e.printStackTrace();
}
out.flush();
}catch(Exception e){
e.printStackTrace();
}
return mapping.findForward("shopprint");
}
页面:shopprint
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="com.dahe.huigou.action.mutiTimeLineChart"%>
<%
String fileName = (String)request.getAttribute("filename");
String imgURL=request.getContextPath()+"/servlet/DisplayChart?filename="+fileName;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
无标题文档