Abhishek Bhardwaj
Abhishek Bhardwaj

Reputation: 300

Spring mvc form validation using hibernate validator

How to display a custom message or remove input for integer field in jsp form when user enters white-space in input-field in spring mvc, validated using hibernate validator? It currently shows:

Failed to convert property value of type java.lang.String to required type int for property freePasses; nested exception is java.lang.NumberFormatException: For input string: ""

Upvotes: 1

Views: 857

Answers (1)

Sumesh TG
Sumesh TG

Reputation: 2575

Use wrapper class to declare integer variables so that wrapper class will convert whitespace to null.

or

refer below link for common solution

Hibernate validation annotation - validate that at least one field is not null

Upvotes: 1

Related Questions