I am getting below error for clientId property of type Integer in my MVC application:
below is the initbinder code in the controller class:Code:Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property clientId; nested exception is java.lang.NumberFormatException: For input string: ""
I understand that this error is coming because i am passing spaces in the input field for clientId which is of type Integer.Code:@InitBinder protected void initBinder(WebDataBinder binder) { binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, false)); }
but, what is the solution. one approach is to use client side javascript validation to check the values.. but is their any better approach to resolve the issue. thank you.


Reply With Quote