Struts2国际化文件乱码解决
方法1:使用native2ascii進(jìn)行編碼轉(zhuǎn)換
代碼如下:
native2ascii -encoding UTF-8 GlobalMessages.properties NewGlobalMessage.properties代碼說(shuō)明:
然后再在struts.xml中<struts></struts>之間添加如下代碼即可,即加入國(guó)際化文件:
<constant name="struts.custom.i18n.resources" value="NewGlobalMessage"/>方法2:安裝PropertiesEditor插件
問(wèn)題
在Struct2在讀取語(yǔ)言包properties屬性文件時(shí),如果文件中包含中文,會(huì)出現(xiàn)亂碼。雖然可以native2ascii進(jìn)行解決,但是使用起來(lái)不方便,為了解決這個(gè)問(wèn)題,可以為Eclipse安裝PropertiesEditor插件解決這個(gè)問(wèn)題。
步驟
1、Help->Install New Software
在打開(kāi)窗口“Work with”輸入:http://propedit.sourceforge.jp/eclipse/updates/ 然后Enter即可,選擇PropertiesEditor進(jìn)行安裝即可。安裝過(guò)程中,可能有警告,別管它,點(diǎn)擊是就可以。
2、安裝完畢后,重啟Eclipse。
3、設(shè)置Properties文件和PropertiesEditor關(guān)聯(lián),如果安裝成功,則properties文件圖片會(huì)變成一個(gè)文本中有個(gè)綠色的P。如果還不能用Properites Editor打開(kāi),則文件右擊->Open With->PropertiesEditor即可
轉(zhuǎn)載于:https://www.cnblogs.com/tufujie/p/5148561.html
總結(jié)
以上是生活随笔為你收集整理的Struts2国际化文件乱码解决的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 手把手带你画一个漂亮蜂窝view And
- 下一篇: PostCss 从0开始