JSR 303 is the standard framework that Java provides for the validation of the bean data, which is already included in EE 6. 0. JSR303Specify a validation rule by annotating annotations on bean properties that are similar to @notnull, @Max, and so on, and validate the bean with a standard authentication interface:---------------------------------------------------------------------------Annotation Description---------------------------------------------------------------------------@Null Annotated element must be Null@notnull annotated element cannot be null@asserttrue The annotated element must be a true@assertfalse the annotated element must be false@min (value) The annotated element must be a number whose value must be>=The specified minimum value @max (value) of the annotated element must be a number whose value must be<=The specified maximum value @decimalmin (value) of the annotated element must be a number whose value must be>=The specified minimum value @decimalmax (value) of the annotated element must be a number whose value must be<=The specified maximum value @size (max, min) the size of the annotated element must be within the specified range @digits (integer, fraction) The annotated element must be a number whose value must be within an acceptable range @pas The element that is annotated must be a past date @future The annotated element must be a future date @pattern (value) The annotated element must conform to the specified regular expression---------------------------------------------------------------------------Hibernate Validation is a JSR303a reference implementation that supports the following extended annotations in addition to all the standard checksum annotations: Note Description @email The annotated element must be an e-mail address @length The size of the annotated string must be within the specified range @notempty the annotated string must be non-empty @range The annotated element must be within the appropriate range---------------------------------------------------------------------------Spring4.0 has its own independent data validation framework and supports JSR 303a standard calibration framework. Spring data binding, you can call the verification framework at the same time to complete the data validation work. In Springmvc, the data can be verified directly by the annotation-driven method. Spring's Localvalidatorfactorybean not only implements the validator interface of spring, but also implements the JSR303the validator interface. As long as you define a localvalidatorfactorybean in the spring container, you can inject it into the bean that requires data validation. Spring itself does not provide the implementation of JSR303, so it is necessary to place the jar package of the JSR303 's creator under the classpath. By labeling @Valid annotations on the parameters of the processing method, SPRINGMVC can perform data validation after data binding is complete. In a form that has a JSR303 annotation already marked/a @Valid is labeled before the Command object, and the SPRINGMVC framework invokes the validation framework to enforce the checksum based on the annotated Life check rule after binding the request parameter to the incoming parameter object. SPRINGMVC is a protocol that uses the signature of a processing method to save the results of a checksum: the previous form/The validation result of the command object is saved to the subsequent entry, and the entry for the saved checksum must be of type Bindingresult or Errors, and the two classes are in the Org.springframework.validation package. But one thing to note: The Bindingresult object that needs to be validated and its binding results must appear in pairs, and they must be next to each other and cannot have additional arguments. Bindingresutl is actually a subclass of Errors, and the Errors interface provides a way to get error information, such as GetErrorCount () or getfielderrors (String field). The Bindingresult extends the Errors interface.
JSR 303 Data Validation Framework description in SPRINGMVC