240
Spring MVC Number Validation
In Spring MVC Validation, we can validate the user’s input within a number range. The following annotations are used to achieve number validation:
- @Min annotation – It is required to pass an integer value with @Min annotation. The user input must be equal to or greater than this value.
- @Max annotation – It is required to pass an integer value with @Max annotation. The user input must be equal to or smaller than this value.
Spring MVC Number Validation Example
1. Add dependencies to pom.xml file.
pom.xml
2. Create the bean class
Employee.java
3. Create the controller class
EmployeeController.java
4. Provide the entry of controller in the web.xml file
web.xml
5. Define the bean in the xml file
spring-servlet.xml
6. Create the requested page
index.jsp
7. Create the other view components
viewpage.jsp
final.jsp
Output:
Next TopicCustom Validation