java中 xml 问题 :1 字节的 UTF-8 序列的字节 1 无效。

原创
2017/02/15 16:07
阅读数 2.8K

根本原因是

The cause of this is a file that is not UTF-8 is being parsed as UTF-8. It is likely that the parser is encountering a byte value in the range FE-FF. These values are invalid in the UTF-8 encoding.

就是说字符编码在UTF-8中有特殊含义,或者是没用正确转换过来。

解决方案:

第一,可以直接在XML文件中更改UTF-8为GBK或GB2312

         <?xml   version="1.0"   encoding="GB2312"?> 

第二,可以在Eclipse中更改,在 eclipse 的功能表 [Project]→[Properties],點選 [Resources],在右邊的「Text file encoding」,把原來是系統預設的編碼,改為 「UTF-8」。

还有一种醉人的解决办法:

把xml的encoding属性值UTF-8改为UTF8,这就厉害了

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部