Framework See the frame ...
Compared to the Struts framework itself, Valida Framework is much more invasive to the code, only needs to inherit the ValidatorForm or ValidatorActionForm, which is convenient to use, you don't have to write a lot of verification code in the Form's Validate method, especially some about the input The verification of the content is more complicated. The framework can save a lot of strength, the framework provides a lot of practical verification methods, and if the verification field changes, it is generally not necessary to modify the code directly, change the frame configuration file ..... .
Less nonsense, enter the topic:
Step1) Introduced Validator Framework
In struts-config.xml (nor is it this file, maybe you have multiple profiles, but generally write in this)
In addition, you should also add
This is a resource file, which is installed with an error message displayed on the page.
Struts configuration file:
Xml Version = "1.0" encoding = "ISO-8859-1"?>
form-beans>
Struts-Config>
Step2) Prepare Validator-Rules.xml, validation.xml can easily see the framework requires two files Validator-Rules.xml, validation.xml
The former specifies the rules of the calibration, do not need you to change (unless you have to join your own verifier). This online is everywhere.
The latter is for specific applications, and in most cases you need yourself, an example below:
Validation.xml
XML Version = "1.0" encoding = "ISO-8859-1">
Step 3) FORM will need to be verified ValidatorForm or ValidatorActionform
The difference between these two is that the former is specifically verified for the FORM of a specific name.
Last