源代码是这样的<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><%@ page import="org.jfree.data.general.DefaultPieDataset,org.jfree.chart.ChartFactory,java.awt.Font,org.jfree.chart.plot.PiePlot,org.jfree.chart.servlet.ServletUtilities
" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jfreechart.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<%
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue("市场人员", 20);
dpd.setValue("开发人员", 10);
dpd.setValue("财务人员", 5);
dpd.setValue("其他", 20);
org.jfree.chart.JFreeChart jfc = ChartFactory.createPieChart3D("某公司人员结构图", dpd, true,true,false);
jfc.getTitle().setFont(new Font("宋体",Font.ITALIC,12));
PiePlot piePlot = (PiePlot)jfc.getPlot();
piePlot.setLabelFont(new Font("宋体",Font.ITALIC,12));
jfc.getLegend().setItemFont(new Font("黑体",Font.BOLD,12));
String filename = ServletUtilities.saveChartAsPNG(jfc, 700, 500,null, session);
String graphURL = request.getContextPath()+ "/DisplayChart?filename=" + filename;
%><img src="<%=graphURL%>" width="700" height="500" border="0" usemap="#<%= filename %>">
</body>
</html>
可是在页面中总是显示不了,显示的是叉号、求各位大虾帮忙~
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><%@ page import="org.jfree.data.general.DefaultPieDataset,org.jfree.chart.ChartFactory,java.awt.Font,org.jfree.chart.plot.PiePlot,org.jfree.chart.servlet.ServletUtilities
" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jfreechart.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<%
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue("市场人员", 20);
dpd.setValue("开发人员", 10);
dpd.setValue("财务人员", 5);
dpd.setValue("其他", 20);
org.jfree.chart.JFreeChart jfc = ChartFactory.createPieChart3D("某公司人员结构图", dpd, true,true,false);
jfc.getTitle().setFont(new Font("宋体",Font.ITALIC,12));
PiePlot piePlot = (PiePlot)jfc.getPlot();
piePlot.setLabelFont(new Font("宋体",Font.ITALIC,12));
jfc.getLegend().setItemFont(new Font("黑体",Font.BOLD,12));
String filename = ServletUtilities.saveChartAsPNG(jfc, 700, 500,null, session);
String graphURL = request.getContextPath()+ "/DisplayChart?filename=" + filename;
%><img src="<%=graphURL%>" width="700" height="500" border="0" usemap="#<%= filename %>">
</body>
</html>
可是在页面中总是显示不了,显示的是叉号、求各位大虾帮忙~
解决方案 »
- weblogic10 怎么部署web项目
- 怎么实现发送邮件
- 很简单的spring管理事务为啥不回滚呢 大家快进 求解???
- WebWork+WebSphere+unix 界面出现乱码,请高手帮忙!
- java poi 导入Excel模板
- 关于批量导入数据的问题~
- 数据上传?
- 请问:Servlet与JavaBean
- 客户端调用Servlet的具体过程为何?Servlet对每一个请求是否初始化
- 所属地区,js控件解决方案,求一个
- 当为变量v.destination传来多个值(2个以上)时,总提示错误,说少一个“}”,但传来一个值时,却没有错误,查了半天也没有搞出来,请高手不吝指点,谢谢。
- 数据库导入excel内存溢出问题
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
/**保存图片*/
String filename = ServletUtilities.saveChartAsPNG(chart, 600, 350,info, session);
/**输出图片*/
ChartUtilities.writeImageMap(w, filename, info, false);你还没没有输出图片
PrintWriter w = new PrintWriter(printWriter);
/**保存图片*/
String filename = ServletUtilities.saveChartAsPNG(chart, 600, 350,info, session);
/**输出图片*/
ChartUtilities.writeImageMap(w, filename, info, false);没有输出
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)错误,当然web.xml已经配置了Displaychart类
部分配置 <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/DisplayChart</url-pattern>
</servlet-mapping>jar包肯定在lib目录下啊~