How is the validation string whole or not using spring annotations?
2 answers
@NumberFormat
annotation only applies to subclasses of java.lang.Number ( Integer , Float , Double , BigDecimal , etc.); so it won't work with strings. To do this, you may need to create a custom annotation that checks that the string contains only numbers.
Take a look at the following tutorial; it goes into great detail on how to create custom annotations and use them for validation with Spring: http://softwarecave.org/2014/03/27/custom-bean-validation-constraints/
+2
source to share