5.
业务逻辑控制器Action里的属性也可以用来保存从业务逻辑组件那里得到的返回结果。Struts2将这些值包装成一个Value
Stack对象,并以struts.valueStack保存在request中,传递到视图层。
6. 使用标签
<%@ taglib prefix="s" uri="/struts-tags"%>
7. 国际化
资源文件命名格式
资源文件基名_语言代码_国家代码.properties
在struts.properties中使用struts.custom.i18n.resources=ApplicationResources指定资源文件基名
如果资源文件中包含非西欧字符,需要使用native2ascii messageResources messageResources_zh_CN.
properties转化
/WEB-INF/classes/lee/ApplicationResources_zh_CN.properties
struts.custom.i18n.resources=lee.ApplicationResources
显示国际化信息
1. <s:text name="key"/>
2. <s:property value="%{getText('key')}"/>
8. 表单校验
1. Override ActionSupport类的validate方法
2. 使用Struts2的校验框架
校验文件要和药校验的类在同一路径下。
校验的命名规则:要校验的类名-validation.xml