2012-10-29 2 views
0

저는 웹 개발에 익숙합니다 ... JSP로 영역 그래프를 그리는 중입니다. (연습 버전입니다. 나중에 데이터베이스에서 데이터를 읽는 프로그램을 만들어야합니다.) 내가 오류를 다음 얻을 코드를 실행하려고하면, 나는 ... 방법이 문제를 해결하는 방법 아무 생각 :(jasper/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) 

감사에서 예고편!

EDIT :

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) 

답변

1

무엇을했는지 정말 모르겠어요 당신은 아래에 전달됩니다

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

대신 아래 인수를 기대하고있다 :.

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

PlotOrientation를 제거하고 그 오류를 제거해야합니다.

+0

나는 여전히 같은 오류가 발생합니다 :(이 오류가 문법과 관련이 있습니까? 나는 org.apache가 말하기 때문에 아파치에 관한 오류라고 생각했습니다 ... (미안, 나는 정말로 새롭다. – user1516649

+0

전체 스택 추적입니까? 아니면 더 있습니까? – Lipongo