出自:http://blog.sina.com.cn/s/blog_5dbd1dda0100bjmq.html
web.xml中的配置如下:
<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>
jsp中的代码 :
<%
DefaultPieDataset pie = new DefaultPieDataset();
pie.setValue("管理人员",25);
pie.setValue("营销人员",30);
pie.setValue("其它人员",40);
pie.setValue("软件开发人员",60);
StandardChartTheme standardChartTheme = new StandardChartTheme("name");//
standardChartTheme.setLargeFont(new Font("楷体",Font.BOLD, 12));//可以改变轴向的字体
standardChartTheme.setRegularFont(new Font("宋体",Font.BOLD, 12));//可以改变图例的字体
standardChartTheme.setExtraLargeFont(new Font("隶书",Font.BOLD, 12));//可以改变图标的标题字体
ChartFactory.setChartTheme(standardChartTheme);//设置主题
JFreeChart chart = ChartFactory.createPieChart("公司人员", pie, true, false, false);
String fileName = ServletUtilities.saveChartAsJPEG(chart,400,400,session);
String url = request.getContextPath() + "/DisplayChart?filename=" + fileName;
%>
<img src="<%= url %>" width="400" height="400">