jfreechart中map在jsp页面显示

最近学习了Jfreechart发现资料有点少,找了好久都没有找到Map在jsp显示的详细资料
所以记录一下,供大家学习:、
Action代码:

前面的不用多说,从这里开始:
//map 的名字
String filename = ServletUtilities.saveChartAsPNG(chart, 1030, 520, info, request.getSession());
//这里的file其实就是map的字符串			
String file = ImageMapUtilities.getImageMap(filename, info, toolTipTagFragmentGenerator,
					new StandardURLTagFragmentGenerator());		
String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;
		
request.setAttribute("file", file);
			
request.setAttribute("filename", filename);
			
request.setAttribute("graphURL", graphURL);

配置文件代码:
<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页面代码:

<body>
    ${file }
    <img src="${graphURL }" border=0 usemap="#${filename }">
</body>

这样就好了。

 

你可能感兴趣的:(jfreechart,jfreechart map)