Detailed explanation of the use of Java validation background parameter verification

1、 Foreword

In the background development process, the verification of parameters has become an indispensable link in the development environment. For example, the parameter cannot be null, and email must conform to the format of email. If you make manual if judgment or write regular expression judgment unintentionally, the development efficiency is too slow, and you will inevitably fall behind in the game of time, cost and quality. Therefore, it is inevitable to abstract the verification layer. Here are several solutions.

2、 Several solutions

1. The validity of struts 2 can be configured by XML, which describes the rules and returned information. This method is troublesome and inefficient. It is not recommended

2. The validation bean is developed based on the jsr-303 standard. It is easy to implement by annotation. However, it is only an interface without specific implementation Hibernate validator is a hibernate independent package that can be referenced directly. It implements the validation bean and expands it. The implementation diagram is as follows:

Click here to view the official Chinese manual

Click here to view the latest coordinate address

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>