\jfreechart-1.0.0\lib\下的三個jar文件復制到\j2sdk1.4.2 \lib\和Tomcat 5.0\common\lib\下。
然后在﹕Tomcat 5.0\conf\web.xml里面的<servlet>和<servlet-maipping>中間加入
<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>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
然后我用了下面的jfreeChat.jsp,代碼入下﹕
<%@ page contentType="text/html;charset=BIG5"%>
<%@ page language="java"%>
<%@ page import="org.jfree.data.general.DefaultPieDataset"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="org.jfree.chart.plot.PiePlot"%>
<%@ page import="org.jfree.chart.ChartRenderingInfo"%>
<%@ page import="org.jfree.chart.servlet.ServletUtilities"%>
<%@ page import="org.jfree.chart.urls.StandardPieURLGenerator"%>
<%@ page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@ page import="org.jfree.chart.encoders.SunPNGEncoderAdapter"%>
<%
String filename="",graphURL="";
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("六月", 500);
data.setValue("七月", 580);
data.setValue("八月", 828);
PiePlot plot = new PiePlot(data);//出錯這個地方?
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white); //
chart.setTitle("Welcome to Jfreechart !");
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
out.println("test");
%>
<HTML>
<HEAD>
<TITLE>Welcome to Jfreechart !</TITLE>
</HEAD>
<BODY>
<P ALIGN="CENTER">
<img src="<%=graphURL%>" width=500 height=300 border=0 usemap="#<%=filename%>">
</P>
</BODY>
</HTML>
保存在webapp文件夾下的TEST目錄下。\jfreechart-1.0.0\lib\下的三個同時放在TEST\WEB-INF\lib下。
啟動tomcat 5.028 輸入﹕
http://127.0.0.1/TEST/jfreeChat.jsp
然后出現﹕
無法顯示網頁
----------------------------------*
后來我一步一步的測試 測試到PiePlot plot = new PiePlot(data)﹔的時候 就開始出錯。使tomcat自動關系服務﹐這個問題怎么解決啊﹖我的qq是﹕106110454﹐歡迎來討論…..