繁体   English   中英

jasper / jfreechart异常错误

[英]jasper/jfreechart exception error

我真的是Web开发的新手...我正在尝试在JSP上绘制面积图(这是练习版。后来,我必须使程序能够从数据库读取数据),当我尝试运行代码时我收到以下错误,我不知道如何解决此问题... :(

 <%@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)

如果您查看错误,则说明传递了错误数量的参数。 您正在通过以下内容:

(String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean)

它期望使用以下参数:

(String, String, String, CategoryDataset, boolean, boolean, boolean)

删除PlotOrientation ,它应该摆脱该错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM