html_errors标签引入国际化资源包
public class UserForm extends ActionForm {
@Override
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
String name1 = user.getUsername();
if(name1 != null)
name1 = name1.trim();
if("".equals(name1))
errors.add("username", new ActionMessage("error.username"));
return errors;
}
}
.................
</action-mappings>
<message-resources parameter="cn.user.strutsdemo.application.Application"></message-resources>
<message-resources parameter="cn.user.strutsdemo.application.Application" key="XXX"></message-resources>
(jsp画面对应的这个资源包里显示形式为:
<title><bean:message key="info.title" bundle="XXX"/></title>)
<html:errors bundle="XXX" />
</struts-config>
Application.properties里面中文以unicode码形式保存
Application_en.properties
Application_zh_CN.properties
Application.properties
画面<html:errors/>表示
<html>标签里面不可以再套标签(即标签里面属性值不能也是标签):
<html:submit><bean:message key='info.submit'/></html:submit>
但<input>标签中可以套标签使用:
<input type="submit" value="<bean:message key='info.submit'/>" />