SpringSecurity3 读取中文消息资源(properties)文件,输出乱码的问题

因为Java识别编码为Unicode,而计算机系统编码常常是GBK,UTF8等编码,所以要转换为Unicode编码
这时可以用Java\jdk1.x.x\bin\native2ascii.exe工具。用JDK提供的native2ascii,进行编码转换
用法:native2ascii [-reverse] [-encoding 源文件的编码] [文件 [输出文件]]

例如,把messages_zh_CN1.properties转换成messages_zh_CN2.properties。

先把要转换的文件messages_zh_CN1.properties放到Java\jdk1.x.x\bin\目录下,然后cmd进入bin的当前目录下输入

native2ascii -encoding UTF-8 messages_zh_CN1.properties messages_zh_CN2.properties

回车OKay!

#ascii =>Unicode
native2ascii messages_input.properties messages_zh_CN.properties
#UTF-8=>Unicode
native2ascii -encoding UTF-8 messages_input.properties messages_zh_CN.properties
#GBK=>Unicode
native2ascii -encoding GBK messages_input.properties messages_zh_CN.properties

注意源文件保存时的编码格式,否则转换后,输出时一样有乱码!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值