Home > Back-end >  Spring boot form validation
Spring boot form validation

Time:10-15

I am beginner spring boot, learn form validation there are many don't understand want to ask, the logic of the program is first input "page1" in figure 2 controller, into the form the front-end interface, figure 3 is the interface, and then enter your user id and the content and submit to the "addUser"
1: @ NotBlank the annotations without me now, why display is deprecated

2: the first method in parameter user1 will be automatically add to the ModelAndView, not need new a ModelAndView object to call the addAttribute () method can be passed on to the next page?
The second method of User1 object why must call User1 and not other name? I understand probably because for springmvc injected object will automatically write hump gets smaller as the default name, but this method is not accept the form of the cords? What's the relationship between the automatic injection and
?
3: what th the contents of the label? I did not understand, in the first visit "page1" path in order to prevent abnormal, so may refer to the th middle finger is user1 object, but when the form validation error, th label became BindingResult key value of a class (see tutorial, so I write, I also don't know right, so what is it this content

Really don't understand, poor foundation, hope everybody to give directions

CodePudding user response:

1. Hibernate 6. X, (org. Hibernate. The validator) @ NotBlank under the package, @ NotEmpty was removed, if want to use the validation annotations, you can use (javax.mail. Validation. Constraints) @ NotBlank under the package, @ NotEmpty, (org. Hibernate. The validator) calibration entity class defines the attributes of a set of specifications, (javax.mail. Validation. Constraints) implement the specification,
Found on the Internet,
2. Springboot receives the HTTP request parameters, automatic filling into the parameter, which is about User1 class if you have and request parameters consistent, automatically loaded into the class, we just tend to use the default name to name, but not mandatory,
@ NotBlank needs and @ Valid use together, will be at @ Valid check whether your parameter is null,
3. Don't know much about this way, I'm sorry, I'm sorry, but,

CodePudding user response:

reference 1st floor percentfl response:
1. Hibernate 6. X, (org. Hibernate. The validator) @ NotBlank under the package, @ NotEmpty was removed, if want to use the validation annotations, you can use (javax.mail. Validation. Constraints) @ NotBlank under the package, @ NotEmpty, (org. Hibernate. The validator) calibration entity class defines the attributes of a set of specifications, (javax.mail. Validation. Constraints) implement the specification,
Found on the Internet,
2. Springboot receives the HTTP request parameters, automatic filling into the parameter, which is about User1 class if you have and request parameters consistent, automatically loaded into the class, we just tend to use the default name to name, but not mandatory,
@ NotBlank needs and @ Valid use together, will be at @ Valid check whether your parameter is null,
3. Don't know much about this way, I'm sorry, I'm sorry, but,
thank you very much, the first question to understand the ~

CodePudding user response:

Th: should be thymeleaf the content of the template

CodePudding user response:

reference wzxding reply: 3/f
th: should be the content of the thymeleaf template
haha, I know that is the content of the template, I want to understand the content of the inside the {}
  • Related