1.开源的源码生成路径方法为系统用户的临时文件夹(win7 C:\Users\系统登录用户名\AppData\Local\Temp)
protected static void createTempDir() {
String tempDirName = System.getProperty("java.io.tmpdir");
if (tempDirName == null) {
throw new RuntimeException("Temporary directory system property "
+ "(java.io.tmpdir) is null.");
}
// create the temporary directory if it doesn't exist
File tempDir = new File(tempDirName);
if (!tempDir.exists()) {
tempDir.mkdirs();
}
}
2.如果要取该图片文件,可以用jfree自带的servlet,也可以自定义servlet或action(自定义的后续再写^-^)。
3.jfreee自带servlet方法及使用
在web.xml中配置servlet,并设置拦截的url路径(/jfreechart)
<servlet>
<servlet-name>jfreechart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jfreechart</servlet-name>
<url-pattern>/jfreechart</url-pattern>
</servlet-mapping>
注意源码中图片位置写死了(系统用户的临时文件夹位置),使用默认jfree默认servlet,不能改变图片位置!!!
// Check the file exists
File file = new File(System.getProperty("java.io.tmpdir"), filename);
if (!file.exists()) {
throw new ServletException(
"Unable to display the chart with the filename '"
+ filename + "'.");
}