Skip to content
Advertisement

Validation not working on spring boot and hibernate

I am new to spring boot and hibernate.I have declared a model class Office which is :

JavaScript

I have declared my first main starting class as:

JavaScript

My controller class is:

JavaScript

I have a office.jsp page which is:

JavaScript

My pom.xml is:

JavaScript

When I click the submit button then if the input field in my form are empty,I wanted to validate my form and show the message below the input field like “Please provide valid office name” .But what is happening is that when i hit the submit button then it is going to my error.jsp page but it is not showing any validation message which i have declared above.My error page displaying is:

error.jsp

JavaScript

I am not getting any error in my console in eclipse too.It is just redirecting me in error.jsp page when my form’s field is empty.

Advertisement

Answer

seems jar conflicts issue as org.hibernate.validator:hibernate-validator:jar(javax.validation:validation-api:jar is part of hibernate validator) is part of spring web dependency so no need to add extra dependency which might conflict so recommend to remove below dependencies and build project again by clean install(mvn clean install).

remove below dependencies:

JavaScript

and make sure you access error message below: not required braces and property name match with your actual message property name you defined.(camelcase matters with name).

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement