解决struts ApplicationResources.properties文件不能写中文问题
2013-05-13 16:02
513 查看
下面介绍两个解决办法:
1. 装一个插件 Poperties Editor 就可以解决了!
Poperties Editor介绍:一个在编辑完成后可以将资源文件中的中文编码格式转换为unicode编码的插件,在开发国际化应用程序的时候非常有用http://propedit.sourceforge.jp/eclipse/updates/
安装方法:在线安装Poperties Editor
启动eclipse,点菜单Help -> SoftWare Updates -> find and install->选中Search for new features to install ->next->点击 New Remote site->给这个更新站点取个名字 如:luanma,url ,填写http://propedit.sourceforge.jp/eclipse/updates即可。->点击ok->选中刚才新加的站点名称,点击finish->他会自动找出与你所用的eclipse版本相适应的插件全部选中->后面只要选择install
all即可
->最后会提示你重起你的eclipse 所有的properties文件名的前面都有一个绿色的p字.
注意:当你安装完之后,那个properties文件里有中文,你编译之后它自动就会转化了。
2. 在jdk的bin文件夹里有个专门转unicode的应用程序 native2ascii.exe
具体操作如下:
1) 把你要转换的文字写到一个文件里,如c:/test.txt
例如:内容如下:
hello.error.name = 请输入姓名。
hello.error.hobby = 请至少选择一个爱好。
hello.error.age = 请输入年龄,年龄必须大于{0}。
2) 在cmd方式中转到bin目录,如C:/j2sdk1.4.2_04/bin
3) 输入命令 native2ascii c:/test.txt > c:/out.txt
转出来的内容就是这样的:
hello.error.name = \u8bf7\u8f93\u5165\u59d3\u540d\u3002
hello.error.hobby = \u8bf7\u81f3\u5c11\u9009\u62e9\u4e00\u4e2a\u7231\u597d\u3002
hello.error.age = \u8bf7\u8f93\u5165\u5e74\u9f84\uff0c\u5e74\u9f84\u5fc5\u987b\u5927\u4e8e{0}\u3002
将内容直接粘到 ApplicationResources.properties 文件的相应位置就可以了。
4) 将out.txt里对应的编码替代原文件的编码即可
当然也可以这样
native2ascii -encoding gb2312 ApplicationResources.properties ApplicationResources_zh.properties
1. 装一个插件 Poperties Editor 就可以解决了!
Poperties Editor介绍:一个在编辑完成后可以将资源文件中的中文编码格式转换为unicode编码的插件,在开发国际化应用程序的时候非常有用http://propedit.sourceforge.jp/eclipse/updates/
安装方法:在线安装Poperties Editor
启动eclipse,点菜单Help -> SoftWare Updates -> find and install->选中Search for new features to install ->next->点击 New Remote site->给这个更新站点取个名字 如:luanma,url ,填写http://propedit.sourceforge.jp/eclipse/updates即可。->点击ok->选中刚才新加的站点名称,点击finish->他会自动找出与你所用的eclipse版本相适应的插件全部选中->后面只要选择install
all即可
->最后会提示你重起你的eclipse 所有的properties文件名的前面都有一个绿色的p字.
注意:当你安装完之后,那个properties文件里有中文,你编译之后它自动就会转化了。
2. 在jdk的bin文件夹里有个专门转unicode的应用程序 native2ascii.exe
具体操作如下:
1) 把你要转换的文字写到一个文件里,如c:/test.txt
例如:内容如下:
hello.error.name = 请输入姓名。
hello.error.hobby = 请至少选择一个爱好。
hello.error.age = 请输入年龄,年龄必须大于{0}。
2) 在cmd方式中转到bin目录,如C:/j2sdk1.4.2_04/bin
3) 输入命令 native2ascii c:/test.txt > c:/out.txt
转出来的内容就是这样的:
hello.error.name = \u8bf7\u8f93\u5165\u59d3\u540d\u3002
hello.error.hobby = \u8bf7\u81f3\u5c11\u9009\u62e9\u4e00\u4e2a\u7231\u597d\u3002
hello.error.age = \u8bf7\u8f93\u5165\u5e74\u9f84\uff0c\u5e74\u9f84\u5fc5\u987b\u5927\u4e8e{0}\u3002
将内容直接粘到 ApplicationResources.properties 文件的相应位置就可以了。
4) 将out.txt里对应的编码替代原文件的编码即可
当然也可以这样
native2ascii -encoding gb2312 ApplicationResources.properties ApplicationResources_zh.properties
相关文章推荐
- ApplicationResources.properties文件中文乱码问题的解决
- 解决Struts中ApplicationResources_properties文件不支持中文问题
- Eclipse中如.js,或.properties文件中有中文不能保存的问题的解决方法
- java获得*.properties配置文件的值,解决读取中文时乱码的问题:
- 解决Properties文件中的中文显示乱码问题
- 解决JasperReport生成PDF文件,中文不能显示的问题
- <util:properties/>加载的配置文件中有中文导致乱码,如何通过分析源码解决问题?
- Java读取properties文件中文乱码问题解决
- Java工程Properties配置文件注释中文,会自动转换为其他编码方式问题解决
- myeclipse中.properties文件不能输入中文的解决办法
- 关于eclipse导入项目properties文件中文编码乱码问题的解决
- Java读写.properties文件实例,解决中文乱码问题
- 解决Java读取properties文件中文乱码的问题
- 解决eclipse编辑时文件不能保存中文的问题
- Poperties Editor 插件------自动解决ApplicationResources.properties中汉字乱码问题
- Java读取properties文件中文乱码问题解决
- Java读取properties文件中文乱码问题的解决
- Java读取properties文件中文乱码问题解决
- edlipse编辑.properties文件中文乱码问题解决
- spring使用@Value注解读取.properties文件时出现中文乱码问题的解决