How to customize property type conversion errors in Spring MVC 3.

How to customize property type conversion errors in Spring MVC 3.

Hi,

I have readed "Spring 3 MVC Validation Example" http://www.roseindia.net/tutorial/spring/spring3/web/spring-3-mvc-validation-example.html.

In the validation form example, I have populated age's imput with a string "hello". After send the form, I receive a type conversion error:

Failed to convert property value of type java.lang.String to required type java.lang.Integer for property age; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "hello" from type java.lang.String to type java.lang.Integer; nested exception is java.lang.IllegalArgumentException: Unable to parse hello

Is it possible to customize this error message? I'd like to say something user-friendly.

Thanks in advance,

ATV.

View Answers

February 10, 2011 at 5:57 PM

Please visit the following link:

Spring Tutorials


February 10, 2011 at 6:12 PM

Hi,

According to http://stackoverflow.com/questions/4082924/jsr-303-type-checking-before-binding/4083198#4083198 I have modified message properties in order to add the follows:

typeMismatch=A numeric value was expected!

Thanks.

ATV









Related Tutorials/Questions & Answers:
How to customize property type conversion errors in Spring MVC 3.
How to customize property type conversion errors in Spring MVC 3.  Hi, I have readed "Spring 3 MVC Validation Example" http://www.roseindia.net... the form, I receive a type conversion error: Failed to convert property value
Spring 3 MVC Validation Example
Spring 3 MVC Validation Example This tutorial shows you how to validate Spring 3 MVC based applications. In Spring 3 MVC annotation based controller has.... Here is the video tutorial of "How to validate a form in Spring MVC 3?"
Advertisements
School Timetable System in java spring mvc 3
School Timetable System in java spring mvc 3  I want to do project in timetable generation for my project. but i dont know how generate. i'm using java spring Hibernate. please some one help me. Thanks thuva
Spring 3 MVC Login Form Example
Spring 3 MVC Login Form Example  Spring 3 MVC Login Form Example...()); } My question is that, using above code how WEB-INF/views/simpleForm.jsp page...); } "how WEB-INF/views/formoutput.jsp page is called?? please help me
Spring 3 MVC Login Form Example
Spring 3 MVC Login Form Example  Spring 3 MVC Login Form Example...()); } My question is that, using above code how WEB-INF/views/simpleForm.jsp page...); } "how WEB-INF/views/formoutput.jsp page is called?? please help me
Spring 3 MVC hello world, Spring 3.0 Web MVC Example
Spring 3 MVC Hello World Example Getting stated with the Spring 3 MVC...;> <title>Spring 3, MVC Examples</title> </head> <body> <h1>Spring 3, MVC Examples</h1> <ul> <
Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes
Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes  I referred your tutorial "Spring 3 MVC and Hibernate 3 Example" and downloaded your source codes. I created a build.xml and built it using ant. And copied
Spring 3 MVC and Hibernate 3 Example Part 3
"> <title>Spring 3 MVC and Hibernate 3 Example application...; <body> <h1>Spring 3 MVC and Hibernate 3 Example application...;} } ArticleController.java This is the spring controller
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database  How to configure Spring MVC and Hibernate with DWR 3, Simple example -- reading a table, editing-deleting and adding new rows
Spring 3 MVC and Hibernate 3 Example Part 1
Spring 3 MVC and Hibernate 3 Example application using Annotations This tutorial explains how to use annotations with spring 3 MVC and hibernate 3 based..._TO_REPLACE_2 web.xml:ADS_TO_REPLACE_3 You must be aware of how spring is configured
Spring 3 MVC and Hibernate 3 Example Part 2
dispatcher-servlet.xml: <context:property-placeholder> element specifies..._TO_REPLACE_1 <tx:annotation-driven> element specifies spring to look... of session bean of type
Spring 3 MVC Login Form Example with Database MySql
Spring 3 MVC Login Form Example with Database MySql  Sir i have checked your project of Spring 3 MVC Login Form Example But Sir Not able to do It with database Mysql. Can you Provide code for login with database. Thanks
Type Conversion - Java Beginners
Type Conversion   Hai, rajanikanth, Please explain how to convert from integer value to a string value .In a database operation i want to convert... for conversion
How to validate form using Spring MVC?
How to validate form using Spring MVC?  Hi, I want to validate a form in Spring MVC using the annotation. How to validate a form in Spring MVC. I... to validate form using Spring MVC? How to use annotation for validation? Thanks
Spring MVC
application. Here are tutorials of Spring MVC: Spring MVC Tutorials Spring 3 MVC Login Form Example Spring 3 MVC Validation Example Spring 3 MVC Registration...Spring MVC  Hi, What do you understand by Spring MVC? Thanks  
Spring MVC
application. Here are tutorials of Spring MVC: Spring MVC Tutorials Spring 3 MVC Login Form Example Spring 3 MVC Validation Example Spring 3 MVC Registration...Spring MVC  Hi, What do you understand by Spring MVC? Thanks  
Hibernate 3 Query Example Part 2
Hibernate 3 Query Example Part 2       Hibernate 3 Query Example Part 2 This tutorial  explains  how to create  Hibernate 3 query example with Spring 3 
How to do Static Resources Configuration in Spring MVC?
How to do Static Resources Configuration in Spring MVC?  Hi, I want to know How to do Static Resources Configuration in Spring MVC? thanks
Data Conversion from int to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from int primitive type to another data type like String, boolean and char etc
Data Conversion from String to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from String primitive type to another data type like int, boolean and char etc
Data Conversion from short to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from short primitive type to another data type like String, boolean and char etc
Data Conversion from byte to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from byte primitive type to another data type like String, boolean and char etc
Data Conversion from float to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from float primitive type to another data type like String, boolean and char etc
Data Conversion from double to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from double primitive type to another data type like String, boolean and char etc
Data Conversion from long to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from long primitive type to another data type like String, boolean and char etc
Spring mvc
Spring mvc  what is spring mvc
HSSFCell to String type conversion
HSSFCell to String type conversion  Hello, Can anyone help me convert HSSFCell type to string. There is a solution in the following URL, but the method getWorkbook() is not defined for the class HSSFCell. Thanks in advance
Spring 3 MVC File Upload, Spring MVC File Upload
Spring 3 MVC File Upload Creating file upload example using Spring 3 MVC Learn how to create file upload application using Spring MVC module of the Spring...;Spring 3, MVC Examples</h1> <ul> <li><a href
How Spring MVC Module Works
How Spring MVC Works      How Spring MVC Works? In this we will see the request flow for the spring framework... of Spring MVC module. The Spring MVC modules comes with the Spring
Spring 3.0 MVC Form, Spring 3.0 MVC Form Example
Spring 3 MVC Form Example In this tutorial we are going to develop Spring 3... of Spring 3 MVC forms. After completing this tutorial you will be able to understand the Spring 3 MVC based applications and use the knowledge gained here
Introduction to Type conversion in Struts
Introduction to Type conversion in Struts Type conversion is a mechanism... this powerful and important facility. In struts the type conversion is an mechanism... are converted into complex bean properties using this type conversion mechanism
Spring 3
Spring 3  Hi I want to know how to write code Spring 3 for registration and login pages with help of data bse.Please help me I am new to Spring
Type conversion example
Type Conversion Example An example of type conversion is given below, which... in yyyy-mm-dd format Now make a type conversion class.ADS_TO_REPLACE_4 The class...;/title> <style type="text/css">@import url(css/main.css);<
Spring 2.5 MVC File Upload
Spring 2.5 MVC File Upload       Spring 2.5 MVC File Upload This tutorial explains how to upload file in Spring 2.5 MVC Framework. Spring MVC module of Spring framework
Introduction to spring 3, Spring framework 3
Introduction to spring 3 In this section we will discuss about Spring 3 framework. Finally Spring 3 is here with new features and enhancements. The Spring... the components selectively. You can use IoC container of spring and any other MVC
Spring 3 MVC Login Form Example
Spring 3 MVC Login Form Example In this tutorials we are showing you...;title>Spring 3, MVC Examples</title> </head> <body> <h1>Spring 3, MVC Examples</h1> <ul> <li>
Spring 3 MVC Registration Form Example
Spring 3 MVC Registration Form Example In this tutorial we are create...;> <title>Spring 3, MVC Examples</title> </head> <body> <h1>Spring 3, MVC Examples</h1> <ul>
How a simple "Hello World" can be displayed using Spring 3.2 MVC?
How a simple "Hello World" can be displayed using Spring 3.2 MVC?  Hi, How a simple "Hello World" can be displayed using Spring 3.2 MVC? Thanks,   Hi, I found very useful reference site for Spring 3.2 MVC Hello
Spring MVC Tutorials
; Spring 3 MVC hello world Example tutorial - Tutorial on developing Spring 3 MVC hello world example - This tutorial teaches you how to develop... shows you how to validate the form.   Spring 3 MVC
spring MVC frame work - Spring
spring MVC frame work  Example of spring MVC frame work
spring MVC - Spring
spring MVC  what is the use of applicationcontext.xml,[servelt-name]-servlet.xml,properties file in spring MVC module
How can you handle form in Spring 3.2 MVC?
How can you handle form in Spring 3.2 MVC?  Hi, How can you handle... the How can you handle form in Spring 3.2 MVC?   Hi, This article.... For more please visit the How can you handle form in Spring 3.2 MVC
Spring 4 MVC Hello World Example: Spring 4 MVC Tutorial will full source code
Video Tutorial of Spring 4 MVC: This video tutorial teaches you how to write.... First of you will learn Features of Spring 4 Framework and How Spring MVC... of: "How to Build Spring 4 MVC Web Application In Eclipse using Maven?"ADS
quartz schedular in spring mvc
quartz schedular in spring mvc  how to apply auto emailing through sping mvc and want to pass some variable to that trigger job
Spring MVC Say Hello Example
with the development of form based application in Spring MVC. You will learn how... Say Hello application in Spring 2.5 MVC   ... the spring tag library and other is <taglib-location> tag that told us where
Spring MVC framework Features
This section contains the unique features of Spring MVC web framework
Spring 3, Spring 3.0, Spring Framework, Spring Framework Tutorial
Binding, and Type Conversion Spring Expression Language (SpEL) Aspect... Spring 3 Hello World Example Spring MVC Tutorials...Spring 3 In this tutorial we will learn Spring 3 Framework with the help
property datasource required - Spring
property datasource required  Hi I am using java springs I am using mysql as backend I am getting one error when i compile the application.property... the following link: http://www.roseindia.net/spring/jdbc-template-batch-update.shtml
Spring 3 MVC Example
com.pugwoo - spring-mvc-conf version 0.2.3 Maven dependency. How to use spring-mvc-conf version 0.2.3 in pom.xml?
com.pugwoo  - Version 0.2.3 of spring-mvc-conf Maven dependency? How to use  com.pugwoo  - Version 0.2.3 of spring-mvc-conf in pom.xml? How... How to add Gradle  dependency? How to use  com.pugwoo - spring-mvc

Ads