当前位置:网站首页>@Detailed explanation of valid annotation usage
@Detailed explanation of valid annotation usage
2022-06-25 06:18:00 【WD Technology】
First of all we have Employee The properties of the class are annotated as follows :
package com.zyq.beans;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
/**
* The employee object
*
* @author sunnyzyq
* @since 2019/12/13
*/
public class Employee {
/** full name */
@NotBlank(message = " Please enter name ")
@Length(message = " Names cannot exceed {max} character ", max = 10)
public String name;
/** Age */
@NotNull(message = " Please enter age ")
@Range(message = " The age range is {min} To {max} Between ", min = 1, max = 100)
public Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
And then again Controller On the corresponding method , Mark the employee with @Valid annotation , Indicates that we need to verify the properties of this object 
边栏推荐
- SAP ui5 beginner tutorial 25 - using proxy server to solve the cross domain problem of SAP ui5 application accessing remote OData service trial version
- Tencent and China Mobile continued to buy back with large sums of money, and the leading Hong Kong stocks "led" the market to rebound?
- Invalid bound statement (not found)
- PHP and WMI – explore windows with PHP
- 【LeetCode】40. Combined summation II (2 strokes of wrong questions)
- Netstat command – displays network status
- Guess the size of the number
- Global and Chinese kaolin market operation scale and investment development proposal report 2022
- Soft exam information system project manager_ Management Science (Operations Research) -- senior information system project manager of soft test 033
- Lesson 9: workspace introduction
猜你喜欢
Wind farm visualization: wind farm data

Wireless industrial Internet of things data monitoring terminal

Distributed solar photovoltaic inverter monitoring
![[hand torn STL] Stack & queue](/img/db/d05c52f8e3fb0aade51460e86cf623.jpg)
[hand torn STL] Stack & queue

Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop

Rhcsa--- day 6 operation
[kicad image] download and installation
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!

Lesson 9: workspace introduction
Vscode voice notes to enrich information (Part 1)
随机推荐
[data visualization application] draw spatial map (with R language code)
How to use asemi FET 7n80 and how to use 7n80
[golang] leetcode intermediate - Search rotation sort array & search two-dimensional matrix II
Linus' speech recordings, which were lost in 1994, were made public
Understanding the dynamic mode of mongodb document
【LeetCode】40. Combined summation II (2 strokes of wrong questions)
[Suanli network] technological innovation of Suanli Network -- Key Technologies of green and security
Ethernet
Leetcode topic [array] -36- effective Sudoku
SAP ui5 beginner tutorial 25 - using proxy server to solve the cross domain problem of SAP ui5 application accessing remote OData service trial version
Optimal Parking
Handling skills of SQL optimization (2)
[network security] sharing of experience and ideas of an emergency battle
50 days countdown! Are you ready for the Landbridge cup provincial tournament?
MV command – move or rename files
RM command – remove file or directory
C simple operation mongodb
China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
Highway
You can't specify target table for update in from clause error in MySQL