I am starting a new Spring-MVC project. Validation is an important function in any project. Thus, I saw many approaches as follows:
This sounds like a validation of Struts 1.x. In my opinion, this is not clever.
I think this is better than the Validator interface
It looks agile, but I don't know if it supports a collection-based property.
So what is the most AGILE APPROACH to validate your Spring-MVC command? And why? Consider many features, such as a collection-based property, custom validation, etc. If you know / use a different approach in Spring-MVC, feel free to share it.
Yours faithfully,
"Agile" means different things to different people :-)
, Hibernate Validator , Hibernate ORM, ONCE ( ) , , - , , 4.0 beta JSR 303, , , .
Validator 3.1 , / ( , , ). 4.0 beta, , .
- .
Spring Validator ? . ?
public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "error.blank.email", "Email address is required."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.blank.name", "Name is required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phone", "error.blank.phone", "Phone is required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "question", "error.blank.question", "Question is required"); }
!
Source: https://habr.com/ru/post/1714642/More articles:Best way to notify observers in MVC? - designUnable to include file in php - phpSite binaries in an asp.net site project? - binaryDifference between deftype in Common Lisp and scheme - schemeHow to get the current portal login URL in DotNetNuke? - c #Where can I find a good example of using GAsyncQueue between a process and a thread - c ++Auto-complete with local data in Rails - ruby-on-railsIterating through a "linked list" in a single SQL query? - sqlInsert a string after a specific character in Ruby - ruby | fooobar.comCheckbox .NET TreeView Control - c #All Articles