2

我尝试使用此代码,但出现错误。该代码在java项目中工作,但当我将它添加到这样的jsp文件时不起作用<% grafik.ciz()%>

  package yazlab;

import java.awt.*;
import java.io.*;
import org.jfree.chart.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.category.*;
import org.jfree.data.category.*;
import org.jfree.data.general.*;


public class grafik
{

public static void ciz()
{
      final DefaultPieDataset data = new DefaultPieDataset();
      data.setValue("One", new Double(43.2));
      data.setValue("Two", new Double(10.0));
      data.setValue("Three", new Double(27.5));
      data.setValue("Four", new Double(17.5));
      data.setValue("Five", new Double(11.0));
      data.setValue("Six", new Double(19.4));

      JFreeChart chart = ChartFactory.createPieChart
      ("Pie Chart ", data, true, true, false);

     try
     {
         final ChartRenderingInfo info = new 
         ChartRenderingInfo(new StandardEntityCollection());
          final File file1 = new File("C:\\Users\\Lycanthrope\\Desktop\\piechart.png");
          ChartUtilities.saveChartAsPNG(
           file1, chart, 600, 400, info);
      } 
     catch (Exception e)
     {
      System.out.println(e);
     }
}
}

org.apache.jasper.JasperException。我在我的项目 jcommon 和 jfreechart 中添加了两个 .jar 文件。我该如何解决?

4

1 回答 1

0

尝试将图表图像路径放在jsp中

<div class="chartimage">
<img src="C:/Users/Lycanthrope/Desktop/piechart.png" height="500px" width="500px"/>
</div>
于 2012-10-27T20:34:51.657 回答