在tomcat中如何配置jfeechart???(在线等)
如题,我照网上说的,
下载了jfreechart-1.0.5.zip,
将jfreechart-1.0.5.zip中的lib路径下的jar文件拷贝到tomcat的common/lib路径下,
修改tomcat的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>
测试demo文件:http://localhost:8000/mydesign/jfreechart.jsp
(我改了端口)
jfreechart.jsp代码:
<%@ page contenttype= "text/html;charset=gbk "%>
<%@ 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 "%>
<%
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());
//500是图片长度,300是图片高度
string filename = servletutilities.savechartaspng(chart, 500, 300, info, session);
string graphurl = request.getcontextpath() + "/servlet/displaychart?filename= " + filename;
%>
<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>
但,出现问题啊:
tomcat中报错:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /a.jsp(1,1) Page directive has invalid attribute: contenttype
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:305)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:99)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:550)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2220)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Validator.validate(Validator.java:1447)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
有哪个高手可以帮帮忙啊???
在线等~~~~~~~~
谢了~~~~~~~
[解决办法]
org.apache.jasper.JasperException: /a.jsp(1,1) Page directive has invalid attribute:
你有个a.jsp?它不是报的这个文件的错吗?
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html