编码 GBK 的不可映射字符

完善api-doc,用eclipse生成javadoc的时候发生“编码 GBK 的不可映射字符 ”,其实是字符编码问题。 
打开eclipse,project -> Generate javadoc 一项一项的选你要输出javadoc的项目,在VM设置中加入以下代码

1
-encoding utf- 8  -charset utf- 8

这次操作,输出的html代码不会发生“编码 GBK 的不可映射字符 ”问题,而且html字符编码都设为了UTF-8,问题彻底解决。 
对应的ant target 如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
< target  name = "javadoc" >
         < echo >+---------------------------------------------------+</ echo >
         < echo >|  Building Doc File                                |</ echo >
         < echo >+---------------------------------------------------+</ echo >
         < javadoc  access = "protected"
                  additionalparam = "-encoding utf-8 -charset utf-8 "
                  author = "true"
                  classpath = "${classes.dir}"
                  destdir = "${doc.dir}/api"
                  nodeprecated = "false"
                  nodeprecatedlist = "false"
                  noindex = "false"
                  nonavbar = "false"
                  notree = "false"
                  packagenames = "org.xxx.common.web.tag.go"
                  source = "1.6"
                  sourcepath = "${src.dir}"
                  splitindex = "true"
                  use = "true"
                  version = "true"
         >
             < link  href = "http://java.sun.com/javase/6/docs/api/"  />
         </ javadoc >
     </ target >

更为彻底的办法就是修改eclipse.ini文件,在末尾加入如下两行内容:

1
2
-Dfile.encoding=UTF- 8
-Dsun.jnu.encoding=UTF- 8


本文转自sucre03 51CTO博客,原文链接:http://blog.51cto.com/sucre/1238811,如需转载请自行联系原作者
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页