一个关于JFreeChart的问题,困扰我好长时间了,请各位达人指教 yeyu710(叶雨) 我现在已把图删了,哈哈,更搞笑,生成新的图了,数据是对的,可是在网页上还是以前的图,好象网页把以前的那个旧图给保存了,我晕 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我LINECHART3D怎么不出数据啊,它的DATESET应该和BARCHART3D一样啊 LZ可能是存成图片文件的吧,这样可能有问题。我是这样做的: //把图片存成流,放在SESSION里 ChartRenderingInfo info = new ChartRenderingInfo(); ByteArrayOutputStream baosChart = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(baosChart,chart,540,300,info); session.setAttribute("chart" + sChartID,baosChart);界面上:<img name="chart" src="servlet/displayChart?id=<%=sChartID%>" border="0">用专门显示的SERVLET输出。sChartID可以用使用时间等数值,这样基本就不会重了。 public class displayChart extends HttpServlet{ public synchronized void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //取得图表的ID String sChartID = req.getParameter("id"); if(sChartID == null) { throw new ServletException("Parameter 'id' is missing!"); } //从session中取到已经画好的图表 HttpSession session = req.getSession(); ByteArrayOutputStream baosOut = (ByteArrayOutputStream)session.getAttribute("chart" + sChartID); //输出该图表 byte[] byContent = baosOut.toByteArray(); ServletOutputStream out = res.getOutputStream(); out.write(byContent, 0, byContent.length); //清空session session.setAttribute("chart" + sChartID, null); return; } public void init(ServletConfig s) throws ServletException { super.init(s); } public void destroy() { super.destroy(); }} 继承LabelGenerator,重实现LabelGenerator congliu(取次花丛都不顾,半缘修道半缘君。) 您能写的再细些吗?这个LabelGenerator是干嘛用的呢?多谢多谢knight12(12Knight) 您这个方法应该可以,可是改动的太多了,我一个action就1万多行,好多action的,实在没办法改了。 那就动态生成图片的名称,比如SESSIONID+时间,这样可以确保每次生成的文件是不重名的,处理完了注意删掉就可以了。 问题应该是浏览器cache吧在html中加入相应的meta说明具体语句问google 还是生成不同的文件名,不过在生成前先删除一下,唉,改动好多,就这几行代码要改好几天,哭死好几个1万多行的class iDay(鱼头) 浏览器的三个报头值为Cache-Control、Pragma、Expires这三个都不好使的,查过,试过,失败了 各位亲朋好友,大侠们帮我看一下Struts2问题 求页面的代码,高手请入 初学struts疑问 Java操作Excel单元格 web service 客户端返回list为空的问题 hibernate配置hbm.xml的问题.关系好复杂,晕忽忽的......请前辈帮忙 如何让Apache+Tomcat自动处理页面链接地址传参数的中文转换? 请教几个XSLT的问题! 请大家看看我的设计合理吗? Tomcat能否支持2000人同时在线?? 如何判断超时问题,请各位高手指教!!!谢谢!!! java Date如何写入MySql字段类型为datetime中?
我是这样做的:
//把图片存成流,放在SESSION里
ChartRenderingInfo info = new ChartRenderingInfo();
ByteArrayOutputStream baosChart = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(baosChart,chart,540,300,info);
session.setAttribute("chart" + sChartID,baosChart);界面上:
<img name="chart" src="servlet/displayChart?id=<%=sChartID%>" border="0">
用专门显示的SERVLET输出。sChartID可以用使用时间等数值,这样基本就不会重了。
{
public synchronized void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
//取得图表的ID
String sChartID = req.getParameter("id");
if(sChartID == null)
{
throw new ServletException("Parameter 'id' is missing!");
} //从session中取到已经画好的图表
HttpSession session = req.getSession();
ByteArrayOutputStream baosOut =
(ByteArrayOutputStream)session.getAttribute("chart" + sChartID); //输出该图表
byte[] byContent = baosOut.toByteArray();
ServletOutputStream out = res.getOutputStream();
out.write(byContent, 0, byContent.length); //清空session
session.setAttribute("chart" + sChartID, null);
return;
} public void init(ServletConfig s) throws ServletException
{
super.init(s);
} public void destroy()
{
super.destroy();
}
}
您能写的再细些吗?这个LabelGenerator是干嘛用的呢?多谢多谢
knight12(12Knight)
您这个方法应该可以,可是改动的太多了,我一个action就1万多行,好多action的,实在没办法改了。
在html中加入相应的meta说明
具体语句问google
好几个1万多行的class
浏览器的三个报头值为Cache-Control、Pragma、Expires这三个都不好使的,查过,试过,失败了