類型轉換器:
數據校驗:
數據校驗案例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<field name="name">
<field-validator type="requiredstring">
<message>姓名不能夠爲空!</message>
</field-validator>
<field-validator type="stringlength">
<param name="minLength">4</param>
<param name="maxLength">16</param>
<message>姓名長度必須在${minLength}-${maxLength}之間</message>
</field-validator>
</field>
<field name="age">
<field-validator type="required">
<message>年齡不能夠爲空!</message>
</field-validator>
<field-validator type="int">
<param name="min">4</param>
<param name="max">16</param>
<message>年齡大小必須在${min}-${max}之間</message>
</field-validator>
</field>
<field name="birthday">
<field-validator type="required">
<message>生日不能夠爲空!</message>
</field-validator>
<field-validator type="date">
<param name="min">1990-1-1</param>
<param name="max">2016-12-12</param>
<message>生日必須在${min}-${max}之間</message>
</field-validator>
</field>
<field name="email">
<field-validator type="email">
<message>郵箱格式不正確!</message>
</field-validator>
</field>
<field name="password">
<field-validator type="required">
<message>密碼不能夠爲空!</message>
</field-validator>
</field>
<field name="repassword">
<field-validator type="fieldexpression">
<param name="expression">password == repassword</param>
<message>兩次密碼不一致!</message>
</field-validator>
</field>
</validators>
國際化:
攔截器:
攔截器案例: