struts2校验器

1:jsp里面的name对应如:

 <s:form action="mySelf">
   <s:textfield name="val" label="Requird email"/>
   <s:submit/>
   </s:form>

2:常见mySelf类继承ActionSupport,并且添加字段val

3:创建action-validation.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE validators PUBLIC
          "-//OpenSymphony Group//XWork Validator 1.0//EN"
          "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd" >  
         
<validators>
<field name="val">
<field-validator type="requiredstring">
<param name="trim">true</param>
  <message>指定检验失败的提示信息</message>
</field-validator>
</field>
</validators>

4:strut.xml

<action name="mySelf" class="help.mySelf">
<result name="success">index.jsp</result>
<result name="input">/inter.jsp</result>
</action>

j2ee的配置太恶心了

posted @ 2011-07-18 15:05  attitudedecidesall  Views(126)  Comments(0Edit  收藏  举报