Failed to convert property value of type java.lang.String to required type java.math.BigDecimal for property annualExpectedIncome; nested exception is java.lang.NumberFormatExceptionNormally we can convert such a number to a BigDecimal with the DecimalFormat object, but instead of changing the type of object we're using in our controller method, lets use the @InitBinder to do the conversion for us.
Simply put, this blog is a dumping ground for things I find interesting or worth remembering relating to Java, programming, web, lean, agile, etc, etc.
Wednesday, May 23, 2012
Comma-separated Numbers to BigDecimal in SpringMVC
One of the cool things about SpringMVC is it allows you to convert special cases to objects. A special case might be trying to convert a number such as 6,117,748.00 to a BigDecimal. If you just try to pass it through normally you'll get
Labels:
conversion,
initbinder,
spring,
springmvc
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment