首页 > 编程网络 > 解决jfreechart中文乱码方案整理【图】

解决jfreechart中文乱码方案整理【图】

2009年12月17日 admin 发表评论 阅读评论

这篇博文只是对网上关于jfreechart中文乱码解决方法的一个汇总整理。 :-o

我也是最近要使用到jfreechart这个图表工具,也是碰到了中文乱码这个问题,后来通过搜索(jfreechart图片乱码等关键词)解决了这个乱码,但发现一个问题就是有的文章只是解决了图表中乱码的某一个方面,比如图表标题,而有的文章不是解决图表标题乱码,却能够解决图表X、Y轴上文字和标题乱码以及底部中文乱码,有鉴于此,于是我就将这些解决方法都汇总在了一起,希望对碰到jfreechart中文乱码的朋友有帮助。

下图是一个柱形图表,非常典型的中文乱码(其他形式图表就不说明了,因为柱形非常有代表性):

以上图表对应的jsp文件代码为:

<%@ page contentType="text/html;charset=UTF-8"%>

<%@ page import="org.jfree.chart.ChartFactory,

org.jfree.chart.JFreeChart,

org.jfree.chart.plot.PlotOrientation,

org.jfree.chart.servlet.ServletUtilities,

org.jfree.data.category.CategoryDataset,

org.jfree.data.general.DatasetUtilities,

org.jfree.chart.plot.*,

org.jfree.chart.labels.*,

org.jfree.chart.renderer.category.BarRenderer3D,

java.awt.*,

org.jfree.ui.*,

org.jfree.chart.axis.AxisLocation,org.jfree.chart.title.TextTitle,org.jfree.chart.axis.CategoryAxis,org.jfree.chart.axis.NumberAxis"%>

<%

double[][] data = new double[][] {{1310, 1220, 1110, 1000},{720, 700, 680, 640},{1130, 1020, 980, 800},{440, 400, 360, 300}};

String[] rowKeys = {"猪肉", "niurou","鸡肉", "鱼肉"};

String[] columnKeys = {"广州", "shenzhen", "东莞", "佛山"};

CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);

JFreeChart chart = ChartFactory.createBarChart3D("","肉类","销量",dataset,PlotOrientation.VERTICAL,true,true,false);

CategoryPlot plot = chart.getCategoryPlot();

//设置网格背景颜色

plot.setBackgroundPaint(Color.white);

//设置网格竖线颜色

plot.setDomainGridlinePaint(Color.pink);

//设置网格横线颜色

plot.setRangeGridlinePaint(Color.pink);

//显示每个柱的数值,并修改该数值的字体属性

BarRenderer3D renderer = new BarRenderer3D();

renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

renderer.setBaseItemLabelsVisible(true);

//默认的数字显示在柱子中,通过如下两句可调整数字的显示

//注意:此句很关键,若无此句,那数字的显示会被覆盖,给人数字没有显示出来的问题

renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

renderer.setItemLabelAnchorOffset(10D);

renderer.setItemLabelFont(new Font("宋体", Font.PLAIN, 12));

renderer.setItemLabelsVisible(true);

//设置每个地区所包含的平行柱的之间距离

//renderer.setItemMargin(0.3);

plot.setRenderer(renderer);

//设置地区、销量的显示位置

//将下方的“肉类”放到上方

plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);

//将默认放在左边的“销量”放到右方

plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

String filename = ServletUtilities.saveChartAsPNG(chart, 700, 400, null, session);

String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;

%>

<img src="<%= graphURL %>" width=700 height=400 border=0 usemap="#<%= filename %>">

注意到在以上的图表中,有四个位置的中文乱码

1、  图表标题以及副标题乱码

2、  X轴乱码

3、  Y轴乱码

4、  图表底部乱码

如下图所示:

对这四个位置的乱码分别进行解决:

NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();

CategoryAxis domainAxis = plot.getDomainAxis();

1、  图表标题以及副标题乱码

Font font = new Font("宋体", Font.BOLD, 16);

TextTitle title = new TextTitle("肉类销量统计图", font);

//副标题

TextTitle subtitle = new TextTitle(“副标题”, new Font(“黑体”, Font.BOLD, 12));

chart.addSubtitle(subtitle);

chart.setTitle(title); //标题

2、  X轴乱码

2.1、X轴坐标上的文字:

domainAxis.setTickLabelFont(new Font(“sans-serif”, Font.PLAIN, 11));

2.2、X轴坐标标题(肉类)

domainAxis.setLabelFont(new Font(“宋体”, Font.PLAIN, 12));

3、  Y轴乱码

3.1、Y轴坐标上的文字:

numberaxis.setTickLabelFont(new Font(“sans-serif”, Font.PLAIN, 12));

3.2、Y轴坐标标题(销量):

numberaxis.setLabelFont(new Font(“黑体”, Font.PLAIN, 12));

4、  图表底部乱码(猪肉等文字)

chart.getLegend().setItemFont(new Font(“宋体”, Font.PLAIN, 12));

通过以上设置就解决了中文乱码了,解决中文乱码后的图表如下所示:

对应的完整代码为(jsp):

<%@ page contentType="text/html;charset=UTF-8"%>

<%@ page import="org.jfree.chart.ChartFactory,

org.jfree.chart.JFreeChart,

org.jfree.chart.plot.PlotOrientation,

org.jfree.chart.servlet.ServletUtilities,

org.jfree.data.category.CategoryDataset,

org.jfree.data.general.DatasetUtilities,

org.jfree.chart.plot.*,

org.jfree.chart.labels.*,

org.jfree.chart.renderer.category.BarRenderer3D,

java.awt.*,

org.jfree.ui.*,

org.jfree.chart.axis.AxisLocation,org.jfree.chart.title.TextTitle,org.jfree.chart.axis.CategoryAxis,org.jfree.chart.axis.NumberAxis"%>

<%

double[][] data = new double[][] {{1310, 1220, 1110, 1000},{720, 700, 680, 640},{1130, 1020, 980, 800},{440, 400, 360, 300}};

String[] rowKeys = {"猪肉", "niurou","鸡肉", "鱼肉"};

String[] columnKeys = {"广州", "shenzhen", "东莞", "佛山"};

CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);

JFreeChart chart = ChartFactory.createBarChart3D("","肉类","销量",dataset,PlotOrientation.VERTICAL,true,true,false);

CategoryPlot plot = chart.getCategoryPlot();

//设置字体,不然会中文乱码的

 Font font = new Font("宋体", Font.BOLD, 16); 

 TextTitle title = new TextTitle("肉类销量统计图", font); 

 //副标题 

 TextTitle subtitle = new TextTitle("副标题", new Font("黑体", Font.BOLD, 12)); 

 chart.addSubtitle(subtitle); 

 chart.setTitle(title); //标题

//////////////////////////

NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis(); 

 CategoryAxis domainAxis = plot.getDomainAxis();  

 /*------设置X轴坐标上的文字-----------*/  

 domainAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 11));  

 /*------设置X轴的标题文字------------*/  

 domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));  

 /*------设置Y轴坐标上的文字-----------*/  

 numberaxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));  

 /*------设置Y轴的标题文字------------*/  

 numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));  

 /*------这句代码解决了底部汉字乱码的问题-----------*/  

 chart.getLegend().setItemFont(new Font("宋体", Font.PLAIN, 12));

//设置网格背景颜色

plot.setBackgroundPaint(Color.white);

//设置网格竖线颜色

plot.setDomainGridlinePaint(Color.pink);

//设置网格横线颜色

plot.setRangeGridlinePaint(Color.pink);

//显示每个柱的数值,并修改该数值的字体属性

BarRenderer3D renderer = new BarRenderer3D();

renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

renderer.setBaseItemLabelsVisible(true);

//默认的数字显示在柱子中,通过如下两句可调整数字的显示

//注意:此句很关键,若无此句,那数字的显示会被覆盖,给人数字没有显示出来的问题

renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

renderer.setItemLabelAnchorOffset(10D);

renderer.setItemLabelFont(new Font("宋体", Font.PLAIN, 12));

renderer.setItemLabelsVisible(true);

//设置每个地区所包含的平行柱的之间距离

//renderer.setItemMargin(0.3);

plot.setRenderer(renderer);

//设置地区、销量的显示位置

//将下方的“肉类”放到上方

plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);

//将默认放在左边的“销量”放到右方

plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

String filename = ServletUtilities.saveChartAsPNG(chart, 700, 400, null, session);

String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;

%>

<img src="<%= graphURL %>" width=700 height=400 border=0 usemap="#<%= filename %>">

附录:

1、  在使用前必须先在web.xml中配置一下servlet,配置很简单,可以根据自己具体情况配置,以下是我配置的:

<servlet>

<servlet-name>DisplayChart</servlet-name>

<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>DisplayChart</servlet-name>

<url-pattern>/DisplayChart</url-pattern>

</servlet-mapping>

2、附件中是关于饼图、柱形图、曲线图的使用写法例子,也是从网上搜集而来,感觉还是很不错的,也整理在这里了。

下载地址:http://www.blogjava.net/Files/bbmonkey62/jfreechart.rar

3、关于Jfreechart的简单介绍:

JFreeChart是一组功能强大、灵活易用的Java绘图API,使用它可以生成多种通用性的报表,包括柱状图、饼图、曲线图、甘特图等。它能够用在Swing和Web等中制作自定义的图表或报表中,并且得到广泛的应用。

JFreeChart是开放源代码的免费软件,但是它的支持文档需要付费才能得到。

其下载地址为:http://sourceforge.net/projects/jfreechart/files/

我使用的就是目前最新的版本1.0.13。

非转载说明,本博文章皆为原创,转载本博文章请务必注明文章出处:
转载自子猴博客

本文链接地址: 解决jfreechart中文乱码方案整理【图】


分类: 编程网络 标签: , , , 1,372次浏览
  1. zihou
    2010年1月20日17:04 | #1

    其他图形的乱码解决方法与柱形的解决方法是类似的,所不同的是调用的方法不一样而已,如果有其他图形的乱码还解决不了的,可以在此留言,我尽量给出解决方法。

  2. wenwen
    2010年3月29日15:46 | #2

    你好,我照你的方法配置web.xml,也用你的代码…但是为什么我会出现下面的问题的?
    HTTP Status 500 -

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException: Unable to compile class for JSP:

    An error occurred at line: 6 in the generated java file
    Only a type can be imported. org.jfree.chart.ChartFactory resolves to a package

    An error occurred at line: 7 in the generated java file
    Only a type can be imported. org.jfree.chart.JFreeChart resolves to a package

    An error occurred at line: 8 in the generated java file
    Only a type can be imported. org.jfree.chart.plot.PlotOrientation resolves to a package

    An error occurred at line: 9 in the generated java file
    Only a type can be imported. org.jfree.chart.servlet.ServletUtilities resolves to a package

    An error occurred at line: 10 in the generated java file
    Only a type can be imported. org.jfree.data.category.CategoryDataset resolves to a package

    An error occurred at line: 11 in the generated java file
    Only a type can be imported. org.jfree.data.general.DatasetUtilities resolves to a package

    An error occurred at line: 14 in the generated java file
    Only a type can be imported. org.jfree.chart.renderer.category.BarRenderer3D resolves to a package

    An error occurred at line: 17 in the generated java file
    Only a type can be imported. org.jfree.chart.axis.AxisLocation resolves to a package

    An error occurred at line: 18 in the generated java file
    Only a type can be imported. org.jfree.chart.title.TextTitle resolves to a package

    An error occurred at line: 19 in the generated java file
    Only a type can be imported. org.jfree.chart.axis.CategoryAxis resolves to a package

    An error occurred at line: 20 in the generated java file
    Only a type can be imported. org.jfree.chart.axis.NumberAxis resolves to a package

    An error occurred at line: 35 in the jsp file: /WebRoot/sample02.jsp
    CategoryDataset cannot be resolved to a type
    32:
    33: String[] columnKeys = {“骞垮窞”, “shenzhen”, “涓滆帪”, “浣涘北”};
    34:
    35: CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:

    An error occurred at line: 35 in the jsp file: /WebRoot/sample02.jsp
    DatasetUtilities cannot be resolved
    32:
    33: String[] columnKeys = {“骞垮窞”, “shenzhen”, “涓滆帪”, “浣涘北”};
    34:
    35: CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:

    An error occurred at line: 37 in the jsp file: /WebRoot/sample02.jsp
    JFreeChart cannot be resolved to a type
    34:
    35: CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:
    39: CategoryPlot plot = chart.getCategoryPlot();
    40:

    An error occurred at line: 37 in the jsp file: /WebRoot/sample02.jsp
    ChartFactory cannot be resolved
    34:
    35: CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:
    39: CategoryPlot plot = chart.getCategoryPlot();
    40:

    An error occurred at line: 37 in the jsp file: /WebRoot/sample02.jsp
    PlotOrientation.VERTICAL cannot be resolved to a type
    34:
    35: CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:
    39: CategoryPlot plot = chart.getCategoryPlot();
    40:

    An error occurred at line: 39 in the jsp file: /WebRoot/sample02.jsp
    CategoryPlot cannot be resolved to a type
    36:
    37: JFreeChart chart = ChartFactory.createBarChart3D(“”,”鑲夌被”,”閿�噺”,dataset,PlotOrientation.VERTICAL,true,true,false);
    38:
    39: CategoryPlot plot = chart.getCategoryPlot();
    40:
    41: //璁剧疆瀛椾綋锛屼笉鐒朵細涓枃涔辩爜鐨�
    42:

    An error occurred at line: 45 in the jsp file: /WebRoot/sample02.jsp
    TextTitle cannot be resolved to a type
    42:
    43: Font font = new Font(“瀹嬩綋”, Font.BOLD, 16);
    44:
    45: TextTitle title = new TextTitle(“鑲夌被閿�噺缁熻鍥�, font);
    46:
    47: //鍓爣棰�
    48:

    An error occurred at line: 45 in the jsp file: /WebRoot/sample02.jsp
    TextTitle cannot be resolved to a type
    42:
    43: Font font = new Font(“瀹嬩綋”, Font.BOLD, 16);
    44:
    45: TextTitle title = new TextTitle(“鑲夌被閿�噺缁熻鍥�, font);
    46:
    47: //鍓爣棰�
    48:

    An error occurred at line: 49 in the jsp file: /WebRoot/sample02.jsp
    TextTitle cannot be resolved to a type
    46:
    47: //鍓爣棰�
    48:
    49: TextTitle subtitle = new TextTitle(“鍓爣棰�, new Font(“榛戜綋”, Font.BOLD, 12));
    50:
    51: chart.addSubtitle(subtitle);
    52:

    An error occurred at line: 49 in the jsp file: /WebRoot/sample02.jsp
    TextTitle cannot be resolved to a type
    46:
    47: //鍓爣棰�
    48:
    49: TextTitle subtitle = new TextTitle(“鍓爣棰�, new Font(“榛戜綋”, Font.BOLD, 12));
    50:
    51: chart.addSubtitle(subtitle);
    52:

    An error occurred at line: 57 in the jsp file: /WebRoot/sample02.jsp
    NumberAxis cannot be resolved to a type
    54:
    55: //////////////////////////
    56:
    57: NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
    58:
    59: CategoryAxis domainAxis = plot.getDomainAxis();
    60:

    An error occurred at line: 57 in the jsp file: /WebRoot/sample02.jsp
    NumberAxis cannot be resolved to a type
    54:
    55: //////////////////////////
    56:
    57: NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
    58:
    59: CategoryAxis domainAxis = plot.getDomainAxis();
    60:

    An error occurred at line: 59 in the jsp file: /WebRoot/sample02.jsp
    CategoryAxis cannot be resolved to a type
    56:
    57: NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
    58:
    59: CategoryAxis domainAxis = plot.getDomainAxis();
    60:
    61: /*——璁剧疆X杞村潗鏍囦笂鐨勬枃瀛�———-*/
    62:

    An error occurred at line: 95 in the jsp file: /WebRoot/sample02.jsp
    BarRenderer3D cannot be resolved to a type
    92:
    93: //鏄剧ず姣忎釜鏌辩殑鏁板�锛屽苟淇敼璇ユ暟鍊肩殑瀛椾綋灞炴�
    94:
    95: BarRenderer3D renderer = new BarRenderer3D();
    96:
    97: renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    98:

    An error occurred at line: 95 in the jsp file: /WebRoot/sample02.jsp
    BarRenderer3D cannot be resolved to a type
    92:
    93: //鏄剧ず姣忎釜鏌辩殑鏁板�锛屽苟淇敼璇ユ暟鍊肩殑瀛椾綋灞炴�
    94:
    95: BarRenderer3D renderer = new BarRenderer3D();
    96:
    97: renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    98:

    An error occurred at line: 97 in the jsp file: /WebRoot/sample02.jsp
    StandardCategoryItemLabelGenerator cannot be resolved to a type
    94:
    95: BarRenderer3D renderer = new BarRenderer3D();
    96:
    97: renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    98:
    99: renderer.setBaseItemLabelsVisible(true);
    100:

    An error occurred at line: 105 in the jsp file: /WebRoot/sample02.jsp
    ItemLabelPosition cannot be resolved to a type
    102:
    103: //娉ㄦ剰锛氭鍙ュ緢鍏抽敭锛岃嫢鏃犳鍙ワ紝閭f暟瀛楃殑鏄剧ず浼氳瑕嗙洊锛岀粰浜烘暟瀛楁病鏈夋樉绀哄嚭鏉ョ殑闂
    104:
    105: renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    106:
    107: renderer.setItemLabelAnchorOffset(10D);
    108:

    An error occurred at line: 105 in the jsp file: /WebRoot/sample02.jsp
    ItemLabelAnchor.OUTSIDE12 cannot be resolved to a type
    102:
    103: //娉ㄦ剰锛氭鍙ュ緢鍏抽敭锛岃嫢鏃犳鍙ワ紝閭f暟瀛楃殑鏄剧ず浼氳瑕嗙洊锛岀粰浜烘暟瀛楁病鏈夋樉绀哄嚭鏉ョ殑闂
    104:
    105: renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    106:
    107: renderer.setItemLabelAnchorOffset(10D);
    108:

    An error occurred at line: 105 in the jsp file: /WebRoot/sample02.jsp
    TextAnchor.BASELINE_LEFT cannot be resolved to a type
    102:
    103: //娉ㄦ剰锛氭鍙ュ緢鍏抽敭锛岃嫢鏃犳鍙ワ紝閭f暟瀛楃殑鏄剧ず浼氳瑕嗙洊锛岀粰浜烘暟瀛楁病鏈夋樉绀哄嚭鏉ョ殑闂
    104:
    105: renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    106:
    107: renderer.setItemLabelAnchorOffset(10D);
    108:

    An error occurred at line: 123 in the jsp file: /WebRoot/sample02.jsp
    AxisLocation.TOP_OR_RIGHT cannot be resolved to a type
    120:
    121: //灏嗕笅鏂圭殑鈥滆倝绫烩�鏀惧埌涓婃柟
    122:
    123: plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    124:
    125: //灏嗛粯璁ゆ斁鍦ㄥ乏杈圭殑鈥滈攢閲忊�鏀惧埌鍙虫柟
    126:

    An error occurred at line: 127 in the jsp file: /WebRoot/sample02.jsp
    AxisLocation.BOTTOM_OR_RIGHT cannot be resolved to a type
    124:
    125: //灏嗛粯璁ゆ斁鍦ㄥ乏杈圭殑鈥滈攢閲忊�鏀惧埌鍙虫柟
    126:
    127: plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    128:
    129: String filename = ServletUtilities.saveChartAsPNG(chart, 700, 400, null, session);
    130:

    An error occurred at line: 129 in the jsp file: /WebRoot/sample02.jsp
    ServletUtilities cannot be resolved
    126:
    127: plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    128:
    129: String filename = ServletUtilities.saveChartAsPNG(chart, 700, 400, null, session);
    130:
    131: String graphURL = request.getContextPath() + “/DisplayChart?filename=” + filename;
    132:

    Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

  3. wenwen
    2010年3月29日15:47 | #3

    为什么不能编译文件啊?

  4. 子猴
    2010年3月29日16:18 | #4

    这种错误一般是系统内部出错,我刚看了下你贴出的错误信息,注意到了如下一些错误:
    1、An error occurred at line: 39 in the jsp file: /WebRoot/sample02.jsp
    CategoryPlot cannot be resolved to a type
    2、An error occurred at line: 49 in the jsp file: /WebRoot/sample02.jsp
    TextTitle cannot be resolved to a type
    等等一些类不能被识别的错误。。。。
    给出的建议如下:
    1、请确认所需的jar包已经包含到你的编译环境中,比如包含CategoryPlot类的jar包。
    2、如果也是运行的jsp页面,请确认你的jar包已经放在了运行环境包目录下,请注意:1中所说的编译环境与运行环境是不一样的,编译环境是用来编译类的,而运行环境一般是用来运行jsp文件的,运行环境一般是你系统的项目根目录/WebRoot/WEB-INF/lib,你必须将相关的jar包放在这个目录下才能确保jsp文件正常运行
    我觉得你的错误很可能是以上第2中所说造成的,你可以先这样确认一下,如果还不行,可以再留言,希望能帮到你。

  5. 2010年5月25日05:24 | #5

    我用的是另外一个

  1. 本文目前尚无任何 trackbacks 和 pingbacks.
:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: 注意: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。使用'@all ',将会将评论发送给之前所有其它评论者。请务必注意user必须和评论者名相匹配(大小写一致)。