struts國際化資源檔案如何讀取

2021-09-01 14:16:30 字數 471 閱讀 4758

用resourcebundle類即可。

它有個靜態方法叫getbundle,傳2個引數,乙個是basename,乙個是locale資訊。

然後用它的方法叫getstring,引數裡傳key即可。

看例子:

resourcebundle rb=resourcebundle.getbundle("messageresource",locale);

system.out.println(rb.getstring("user.not.found"));

如果有佔位符的,則用messageformat類即可,例子如下:

messageformat mf=new messageformat(rb.getstring("user.not.found"));

system.out.println(mf.format(new object));

struts2 資源檔案 國際化

資源檔案 國際化 1.新建資源檔案 eg myproperties en us.properties和myproperties zh cn.properties myproperties en us.properties login.name name login.pass password myp...

國際化資源檔案 轉碼

做國際化的時候,中文資源檔案會有亂碼,可以用native2ascii 命令。native2ascii 的jdk自帶的功能。開啟cmd視窗,切換目錄到資源檔案所在的目錄,native2ascii encoding iso 8859 1 1.properties 2.txt 回車 encoding is...

42 國際化 配置package的資源檔案

同樣在建立com.asm包下建立兩個資源檔案 package級別的資源檔名必須以package開頭 取名為 package zh cn.properties,它的內容為 pack pack屬性值和package en us.properties,它的內容為 pack packageattribute...