报错:java.lang.NoClassDefFoundError: org/jfree/data/general/PieDatasetpackage cn.edu.hbmy.drp.util.servlet;import java.awt.Font;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.chart.*;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
/**
* 演示通过servlet直接输出图表
* @author Winter Lau
*/
public class ChartDemoServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{
res.setContentType("image/jpeg");
DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart3D("分销商分布图", // 图表标题
data,
true, // 是否显示图例
false,
false
);
PiePlot3D plot=(PiePlot3D)chart.getPlot();
// 图片中显示百分比:默认方式
//plot.setLabelGenerator(new StandardPieSectionLabelGenerator(StandardPieToolTipGenerator.DEFAULT_TOOLTIP_FORMAT));
// 图片中显示百分比:自定义方式,{0} 表示选项, {1} 表示数值, {2} 表示所占比例 ,小数点后两位
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
// 图例显示百分比:自定义方式, {0} 表示选项, {1} 表示数值, {2} 表示所占比例
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
chart.setTitle(new TextTitle("分销商分布图",new Font("宋体",Font.BOLD,20)));
LegendTitle legend = chart.getLegend();
legend.setItemFont(new Font("宋体",0,12));
//PiePlot plot = (PiePlot)chart.getPlot();
plot.setLabelFont(new Font("宋体",0,10));
ChartUtilities.writeChartAsJPEG(res.getOutputStream(),
1.0f,chart,400,300,null); }
/**
* 获取一个演示用的简单数据集对象
* @return
*/
private static DefaultPieDataset getDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("一级分销商",100);
dataset.setValue("二级分销商",200);
dataset.setValue("三级分销商",300); return dataset;
}
}
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.chart.*;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
/**
* 演示通过servlet直接输出图表
* @author Winter Lau
*/
public class ChartDemoServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{
res.setContentType("image/jpeg");
DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart3D("分销商分布图", // 图表标题
data,
true, // 是否显示图例
false,
false
);
PiePlot3D plot=(PiePlot3D)chart.getPlot();
// 图片中显示百分比:默认方式
//plot.setLabelGenerator(new StandardPieSectionLabelGenerator(StandardPieToolTipGenerator.DEFAULT_TOOLTIP_FORMAT));
// 图片中显示百分比:自定义方式,{0} 表示选项, {1} 表示数值, {2} 表示所占比例 ,小数点后两位
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
// 图例显示百分比:自定义方式, {0} 表示选项, {1} 表示数值, {2} 表示所占比例
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
chart.setTitle(new TextTitle("分销商分布图",new Font("宋体",Font.BOLD,20)));
LegendTitle legend = chart.getLegend();
legend.setItemFont(new Font("宋体",0,12));
//PiePlot plot = (PiePlot)chart.getPlot();
plot.setLabelFont(new Font("宋体",0,10));
ChartUtilities.writeChartAsJPEG(res.getOutputStream(),
1.0f,chart,400,300,null); }
/**
* 获取一个演示用的简单数据集对象
* @return
*/
private static DefaultPieDataset getDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("一级分销商",100);
dataset.setValue("二级分销商",200);
dataset.setValue("三级分销商",300); return dataset;
}
}
解决方案 »
- CAS客户端报错,页面一直停留在CAS服务端登陆页面,不会转跳转到CAS客户端登陆成功后的首面?
- ids for this class must be manually assigned before calling save(): org.hiberna
- 用javamail 读邮件内容出现的异常:javax.mail.internet.ParseException
- 刚学jsp想问问jsp隐式对象和EL表达式中的隐式对象有何区别??
- FTPclient监控启动后无法关闭连接~~
- 数据源配置出错!请帮忙看下!!谢谢各位大虾!
- 碰到了一个难题--jsp连接SQL server数据库不成功,希望给予帮助
- 什么破烂jsp,又是中文问题。
- 错误信息看不懂
- 在jsp中能否得到显示器的分辨率
- jquery 小问题
- linux 下 访问有flash的网页
我加了jar包的
Eclipse为什么不自动发布呢
还要重新发布一下。
以前好像都是只需要发布一次就可以了啊?!