原因:首先,JFreeChart和中文验证码的乱码问题和jsp的编码无关,是由于Java虚拟机找不到字体文件造成的,所以同类的Swing或者AWT的中文乱码问题也适用

环境:
JDK1.5(JDK版本很重要,如果是1.4.2版本的话,JRE目录下的字体配置文件不大一样)
RedHat4.0
Tomcat5.0

解决方法:
1.确认%JavaHome%/jre/lib/fonts目录下存在zysong.ttf
2.在%JavaHome%/jre/lib/fonts目录下执行"ttmkfdir -o fonts.dir"命令,重新生成fonts.dir文件
3.确认/usr/share/fonts/zh_CN/TrueType目录存在,如果不存在则mkdir创建
4.确认/usr/share/fonts/zh_CN/TrueType目录下存在zysong.ttf
5.在%JavaHome%/jre/lib目录下,执行 cp fontconfig.RedHat.3.properties.src fontconfig.properties
6.重新启动tomcat,大功告成!

下面提供下载字体

http://www.javaeye.com/topics/download/0cc6d142-fc8a-466a-921c-158c6732e635

 

在windows下开发的web项目,移植到linux或unix系统下,常导致一些乱码问题,主要是jdk1.5的汉字字体linux和unix支持得不够充分。
     解决方案:拷贝windows的simsun.ttc 到java安装目录的字体目录下,改名为simsun.ttf
服务器上的目录为/opt/jdk1.5.0_02/jre/lib/fonts
然后修改fonts.dir为这样,实际上就是设置为不管什么字体都用简宋体,包括英文
48
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-1
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-1
simsun.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-iso8859-1
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-2
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-2
simsun.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-iso8859-2
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-4
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-4
simsun.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-iso8859-4
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-5
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-5
simsun.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-iso8859-5
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-7
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-7
simsun.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-iso8859-7
simsun.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-iso8859-9
simsun.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-iso8859-9

最后重起服务。



开心过好每一天。。。。。