0
我真的很新的网页开发......我想借鉴JSP区域图(这是实践version..later上,我必须做出计划,从数据库中读取数据) ,当我尝试运行我得到下面的错误代码,我不知道如何解决这个问题... :(碧玉/ jfreechart的异常错误
代码
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.awt.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.chart.labels.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.category.*" %>
<%@ page import="org.jfree.chart.urls.*" %>
<%@ page import="org.jfree.data.category.*" %>
<%@ page import="org.jfree.data.general.*" %>
<%
final double[][] data = new double[][]{
{110, 200, 220, 165, 199},
{100, 204, 101, 101, 240}
};
final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Box", "ape", data);
final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value", dataset, PlotOrientation.VERTICAL,true, true, false);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setForegroundAlpha(0.5f);
chart.setBackgroundPaint(new Color(249, 231, 236));
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String root = getServletContext().getRealPath("/");
String path = root + "\\" + "areachart.png";
final File file1 = new File(path);
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
} catch (Exception e) {
out.println(e);
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<IMG SRC="areachart.png" WIDTH="600" HEIGHT="400" BORDER="0" USEMAP="#chart">
</body>
</html>
错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 31 in the jsp file: /graph.jsp
The method createAreaChart(String, String, String, CategoryDataset, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean)
28:
29: final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Box", "ape", data);
30:
31: final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value", dataset, PlotOrientation.VERTICAL,true, true, false);
32:
33: final CategoryPlot plot = chart.getCategoryPlot();
34: plot.setForegroundAlpha(0.5f);
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
谢谢提前!
编辑:
如果我删除PlotOrientation.VERTICAL ..我得到这个错误是相同的东西? ; /我真的不知道我做错了什么:(
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 31 in the jsp file: /graph.jsp
The method createAreaChart(String, String, String, CategoryDataset, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, CategoryDataset, boolean, boolean, boolean)
28:
29: final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Box", "ape", data);
30:
31: final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", "", "Value",dataset,true, true, false);
32:
33: final CategoryPlot plot = chart.getCategoryPlot();
34: plot.setForegroundAlpha(0.5f);
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
我仍然得到同样的错误:(这个错误是什么做的语法?我认为这是关于Apache的,因为它说org.apache错误......(对不起,我真的很新的,努力工作,我的方式) – user1516649
这是整个堆栈跟踪还是还有更多? – Lipongo