1、下载Eclipse Properties Editor,可协助你编写i18n的properties
http://propedit.sourceforge.jp/eclipse/updates/ (使用Eclipse的网络下载:
help à Software Updates à Find and Install à Search for new ……)
2、在struts-config.xml设定propeties文件的路径(要记得compile到WEB-INF/classes)
<message-resources parameter="ApplicationResource" null="true" />
如果语系设定为中文(台湾) : ApplicationResource_zh_TW.properties
如果语系设定为中文(中国) : ApplicationResource_zh_CN.properties
如果没有对应的语系,则会读取ApplicationResource.properties
3、properties檔是依照key = value去区分的,如果有相同的key,则会读取最后面的
test.name=张三
test.name=李四
4、从IE设定语系:工具à因特网选项à语言
5、使用方式:
ActionMessage ↓ html:errors | ActionMessages msgs = new ActionMessages(); super.saveErrors(request, msgs); |
<html:errors/> | |
<bean:message …./> | <bean:message key="employee.chinese.name"/> |
ActionMessage ↓ html:messages bean:write | ActionMessages msgs = new ActionMessages(); msgs.add("message", new ActionMessage("success.data.add")); super.saveMessages(request, msgs); |
<html:message id=”msg” message=”true”> <bean:write name=”msg” /> </html:message> |