Spring Boot combat Advanced - Chapter 1: Form Validation

form validation

[Pictures of foreign chains dump fails, the source station may have a security chain mechanism, it is recommended to save the picture down directly upload (img-b5T9TODb-1580033091350) (C: \ Users \ test \ AppData \ Roaming \ Typora \ typora-user-images \ image-20200125193858234.png)]

2. Data transmission

Entity Object
Here Insert Picture Description

  • Animal is different from the value of the same class object
    Here Insert Picture Description

3. Verify Data

Verify comment
[Pictures of foreign chains dump fails, the source station may have a security chain mechanism, it is recommended to save the picture down directly upload (img-bNm42htL-1580033091352) (C: \ Users \ test \ AppData \ Roaming \ Typora \ typora-user-images \ image-20200125151127775.png)]

  • (1) data set annotation rules
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DIql7xjQ-1580033091353)(C:\Users\test\AppData\Roaming\Typora\typora-user-images\image-20200125141948033.png)]

  • (2) in the controller is set by the need to verify the annotation @Valid pass over the front end of the parameters in accordance with the above comments, and acquire the authentication information BindingResult result of
    在这里插入图片描述
    the default error message printed result, no error is not suggested zodiac
    在这里插入图片描述

  • (3) custom error message, no error Zodiac is not prompted
    在这里插入图片描述
    to print the results:
    在这里插入图片描述

  • (4) Add the passwords do not match low error messages to result in
    类方法,提高复用性
    在这里插入图片描述

Published 162 original articles · won praise 7 · views 3405

Guess you like

Origin blog.csdn.net/yangshengwei230612/article/details/104088598