Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:23:06+00:00 2026-05-30T11:23:06+00:00

here is my form : <form:form modelAttribute=fooDTO> fooCountry: <form:select path=country> <form:options items=${countries} itemLabel=shortName itemValue=id/>

  • 0

here is my form :

<form:form modelAttribute="fooDTO">
fooCountry: 
<form:select path="country">
  <form:options items="${countries}" itemLabel="shortName" itemValue="id"/> 
</form:select>

here is the backing pojo :

public class FooDTO
{
  private Country country;
 //getters and setters present
}

The selected option defaults to the country value in fooDTO, which is good. But the binding then fails when submitting the form – I get the aformentioned error, do I have to register a custom editor in a binder, or is there a simpler method ? Country is pretty much as you’d expect, and countries is indeed a list of countries populated in the controller …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:23:08+00:00Added an answer on May 30, 2026 at 11:23 am

    Spring 3 introduced the Converter SPI which makes this quite easy. Have a look at 6.5 in the documentation

    Taking source from the docs and putting in your country, you would do something like

    package my.converter;
    
    final class StringToCountry implements Converter<String, Country> {
        public Country convert(String source) {
            return // whatever you do to get a country from your string
        }
    }
    

    Then in the xml config you would configure the converter

    <bean id="conversionService"
          class="org.springframework.context.support.ConversionServiceFactoryBean">
        <property name="converters">
            <list>
                <bean class="my.converter.StringToCountry"/>
            </list>
        </property>
    </bean>
    

    As GriffeyDog pointed out, you may want to put the country id in for the select path so you can get the Country by ID or something instead of whatever is returned by toString() of your Country object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the jsp: <c:if test=${!empty USERS}> <form:form method=post action=requestForFriends.html commandName=user> <form:select path=userName> <c:forEach
I modified this simple countdown timer form here: https://github.com/lunaryorn/snippets/blob/master/qt4/countdown.py as follows. Now I want
To give more information I am using the modular form here: http://jqueryui.com/demos/dialog/#modal-form `b(e.target).zIndex` is
I've been putting together my first Ajax powered form ( here ), with the
Summary Below is the full question (a bit complicated in its full form) here's
The current form is here . It is not complete, and only a couple
I have this form right here, where the user will add the start date
I have this $data array: (built on a shell, not a form) (debugged here)
Here is the input form code <tr valign=top> <td align=right class=innertablestyle><font class=normal><strong>Homepage</strong></font></td> <td>&nbsp;</td> <td>
Here is a simple form I am using to send XML data in admin_xml.php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.