Struts 2
1. 安装PropertiesEditor 插件,http://propedit.sourceforge.jp/index_en.html
2. 在Action所在的包下创建一个package_zh_CN.properties,并写入字符串
3. 在Action类下的用法:
getText("login.invalid.username.password");
4.jsp中的用法:
<s:text name="validation.required" value0="User Name"/>
5. validation的用法:
@Validations(requiredStrings = {
@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "model.departmentName", message = "必须输入部门名称", key = "EtDepartmentAction.department.name.required") })
很好的教程:
http://www.blogjava.net/max/archive/2006/11/01/78536.html
Jmesa
1. 在web.xml中加入:
<context-param>
<param-name>jmesaMessagesLocation</param-name>
<param-value>com/xxx/system/package</param-value>
</context-param>
其中com/xxx/system/package是资源文件(resource bundle)
2. 用titleKey指定key
<jmesa:htmlColumn property="employeeId" titleKey="employee.id" />
让Jmesa使用Struts的bundle文件
1. 在web.xml中加入:
<context-param>
<param-name>EtStrutsMessagesClass</param-name>
<param-value>com.xxx.admin.action.EtCommerceHomeAction</param-value>
</context-param>
其中com.xxx.admin.action.EtCommerceHomeAction是Strtu资源文件(resource bundle)
2. 在jsp中的使用:
<jmesa:tableFacade id="table${actionName}" items="${modelList}"
exportTypes="" stateAttr="restore" var="bean"
toolbar="com.xxx.jmesa.EtToolbar" messages="com.xxx.jmesa.EtStrutsMessages">