代码如下:

native2ascii -encoding UTF-8 GlobalMessages.properties NewGlobalMessage.properties

代码说明:

Struts2国际化文件乱码解决

然后再在struts.xml中<struts></struts>之间添加如下代码即可,即加入国际化文件:

<constant name="struts.custom.i18n.resources" value="NewGlobalMessage"/>

方法2:安装PropertiesEditor插件

问题
在Struct2在读取语言包properties属性文件时,如果文件中包含中文,会出现乱码。虽然可以native2ascii进行解决,但是使用起来不方便,为了解决这个问题,可以为Eclipse安装PropertiesEditor插件解决这个问题。
步骤
1、Help->Install New Software
在打开窗口“Work with”输入:http://propedit.sourceforge.jp/eclipse/updates/ 然后Enter即可,选择PropertiesEditor进行安装即可。安装过程中,可能有警告,别管它,点击就可以。
2、安装完毕后,重启Eclipse。
3、设置Properties文件和PropertiesEditor关联,如果安装成功,则properties文件图片会变成一个文本中有个绿色的P。如果还不能用Properites Editor打开,则文件右击->Open With->PropertiesEditor即可

相关文章:

  • 2021-12-14
  • 2021-05-11
  • 2021-04-10
  • 2021-09-08
  • 2022-01-16
  • 2021-07-16
  • 2021-10-16
猜你喜欢
  • 2021-06-09
  • 2022-01-11
  • 2021-08-03
  • 2021-09-02
  • 2022-12-23
  • 2021-10-27
相关资源
相似解决方案