Spring MVC Custom ValidationThe Spring MVC framework allows us to perform custom validations. In such case, we declare own annotations. We can perform validation on the basis of own business logic. Spring MVC Custom Validation ExampleIn this example, we use both pre-defined annotations as well as custom annotations to validate user input. 1. Add dependencies to pom.xml file.pom.xml 2. Create the bean classEmployee.java 3. Create the controller classEmployeeController.java 4. Create the validator annotationPassword.java 5. Create the validator classPasswordConstraintValidator.java 6. Provide the entry of controller in the web.xml fileweb.xml 7. Define the bean in the xml filespring-servlet.xml 8. Create the requested pageindex.jsp 9. Create the other view componentsviewpage.jsp final.jsp Output: ![]() ![]() Here, we entered the password without having "jtp" sequence. ![]() ![]() Now, we entered the password having "jtp" sequence. ![]() ![]()
Next TopicRemoting in Spring Framework
|