Server-Side Validation-Verify framework validation

Source: Internet
Author: User

Advantages: No need to write code, simplify the workload, modify the validation without modifying the code, to facilitate later maintenance.

Write the XML file file name in the action that needs to be validated. The class name of the action-validation.xml

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE validators Public "-//opensymphony group//xwork Validator 1.0.3//en" "http://www.opensymphony.com/xwork/ XWORK-VALIDATOR-1.0.3.DTD ><validators><!--Set validation rules for fields, name indicates field names, and requires the name of the form element to be consistent--><field name= " UserName "><!--set validation rules enforced on a field, type represents the validation rule type name, requiredstring validation field cannot make a null reference or an empty string--><field-validator type=" Requiredstring "><!--trime parameter indicates that the trim () method is called before judging to remove the string Kinsoku--><param name=" Trim ">true</param> <!--set the error message--><message> Please enter the user name </message></field-validator><field-validatortype= "Stringlength"><param name= "MinLength" >4</param><param name= "MaxLength" >12</param><message> User name length must be between 4-12 </message></field-validator></field> <field name= "password" >< Field-validator type= "requiredstring" ><param name= "trim" >true</param><message key= " Required.password "/></field-validator></field><field name=" Repwd "><field-validatortype= "Requiredstring"><param name= "Trim" >true</param><message> please confirm password </message></field-validator>< Field-validatortype= "Fieldexpression"><param name= "expression" >password==rePwd</param><message> two input passwords must be consistent </message></ Field-validator></field><field name= "Job.id" ><field-validatortype= "Required"><message key= "Required.job"/></field-validator></field><field name= "Birthday" >< Field-validator type= "required" ><message> Please enter your birthday </message></field-validator></field> <field name= "Email" ><field-validator type= "requiredstring" ><param name= "trim" >true</param ><message> Please enter email</message></field-validator><field-validator type= "email" >< Message>email format is incorrect </message></field-validator></field><field name= "url" >< Field-validator type= "requiredstring" ><param name= "trim" >true</param><message> Please enter url</ Message></field-validator><field-validator type= "url" ><message>url format is incorrect </message> </field-validator></field></validators>

Server-Side Validation-Verify framework validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.