※ 引述《cklonger (22)》之銘言:
: 我畫了一個pie chart 然後輸出到jsp page
: 以下是部分的code
: -----
: int b[] = new int[9];
: while(rs3.next())
: {
: b[i3] = rs3.getInt(1);
: i3++;
: }
: String title = "test pipe";
: DefaultPieDataset pieDataset = new DefaultPieDataset();
: pieDataset.setValue("1.廠商資格不當", b[0] );
: pieDataset.setValue("2.採購規格不當", b[1] );
: pieDataset.setValue("3.招標文件草率", b[2] );
: pieDataset.setValue("4.公告刊登錯誤", b[3] );
: pieDataset.setValue("5.妨礙廠商領摽或投標", b[4] );
: pieDataset.setValue("6.開標、審標、決標不公或不當", b[5] );
: pieDataset.setValue("7.履約驗收過程處理不當", b[6] );
: pieDataset.setValue("8.未注意可能有圍標之徵兆", b[7] );
: pieDataset.setValue("9.其他", b[8] );
以下改成
PiePlot3D pieplot = new PiePlot3D(pieDataset);
JFreeChart jfreechart = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT,
pieplot, true);
pieplot.setNoDataMessage("No data available");
pieplot.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
pieplot.setURLGenerator(new StandardPieURLGenerator("a.jsp"));
pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2}
percent)"));
pieplot.setLegendLabelToolTipGenerator(new
StandardPieSectionLabelGenerator("Tooltip for legend item {0}"));
StandardEntityCollection sec = new StandardEntityCollection();
ChartRenderingInfo info = new ChartRenderingInfo(sec);
PrintWriter w = new PrintWriter(out);
String filename = ServletUtilities.saveChartAsPNG(jfreechart, 500, 300,
info, session);
ChartUtilities.writeImageMap(w, "map0", info, false);
String graphURL = request.getContextPath() +
"/servlet/DisplayChart?filename=" + filename;
%>
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#map0"">
</body>
</html>
: ------------------
錯誤訊息
http://blog.pixnet.net/cklonger
奇怪的是我有在 tomcat5.0/conf/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>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
但是jsp仍會出現上述那個錯誤
我把
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#map0"">
拿掉以後會cmopile過 但是圖生在tomcat5.0目錄 下
這個跟我jsp放在自己設定的虛擬目錄下有關係嗎
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.35.93
※ 編輯: cklonger 來自: 61.228.35.93 (11/10 01:34)