In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "what are the three exception capture handling methods of @ Validated and @ Valid". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Catalogue
@ Validated and @ Valid exception catch
There are three kinds of anomalies
The difference between @ Valid and @ Validated
Annotation position
There are three types of exceptions caught by @ Validated and @ Valid exceptions
BindException: form submission is valid and will be invalid for submission in json format
MethodArgumentNotValidException: the preceding paragraph is valid in json format
ConstraintViolationException: add @ RequestParam to the parameter or @ NotBlank @ NotNull to the parameter
The difference between @ Valid and @ Validated
@ Valid is used when using Hibernate validation
@ Validated is used only by the Spring Validator verification mechanism.
Description: java's JSR303 declares interfaces such as @ Valid, while Hibernate-validator implements it
@ Validation encapsulates @ Valid twice, and there is no difference in use, but there are differences in grouping, annotation location, nesting verification and other functions. This article mainly describes these situations.
Annotation position
Validated: used on types, methods, and method parameters. But cannot be used for member attributes (field)
Valid: can be used on methods, constructors, method parameters, and member properties (field)
That's all for "what are the three exception capture handling methods of @ Validated and @ Valid". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.