struts框架下的jfreechart配置问题
Servlet execution threw an exception 运行后的结果
我在Struts框架下,想用图表方式显示查询结果,配置好后tomcat抛出以上错误
具体的思路:jsp传入查询数据,ACTION调用model的方法得到结果集,然后作为调用一个生成图表类,存入request,之后供结果页面Jsp调用
Q1:Servlet execution threw an exception ,我已经在web.xml文件下配置好了文件如下:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " version= "2.4 " xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<servlet>
<servlet-name> action </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
<init-param>
<param-name> config </param-name>
<param-value> /WEB-INF/struts-config.xml </param-value>
</init-param>
<init-param>
<param-name> debug </param-name>
<param-value> 3 </param-value>
</init-param>
<init-param>
<param-name> detail </param-name>
<param-value> 3 </param-value>
</init-param>
<load-on-startup> 0 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name> action </servlet-name>
<url-pattern> *.do </url-pattern>
</servlet-mapping>
<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>
<welcome-file-list>
<welcome-file> login.jsp </welcome-file>
</welcome-file-list>
</web-app>
Q2: String filename=ServletUtilities.saveChartAsJPEG(chart,600,400,info,session);
//设置生成图片,包括图片的大小,长度是300,宽是200
System.out.println(filename);
System.out.println(info);
session.setAttribute( "file_name1 ",filename);
String URL= request.getContextPath() + "/servlet/DisplayChart? filename= " + filename;
session.setAttribute( "file_url1 ",URL);