Announcement Announcement Module
Collapse
No announcement yet.
Spring2 select tag - Failed to convert property value of type [java.lang.String] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring2 select tag - Failed to convert property value of type [java.lang.String]

    Hi
    I'm using the new Spring form taglib to display a drop-down selection of months. The select tag is displayed correctly but when the form is submitted the <form:errors path="month"/> shows the following error:


    Failed to convert property value of type [java.lang.String] to required type [com.leroy.Month] for property month; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found


    This is how I've coded the jsp:

    Code:
    <b>Month: </b><form:select items="${months}" path="month" itemLabel="name" itemValue="id"/>
    <form:errors path="month"/>

    This is how I've coded the controller:

    Code:
    protected Map referenceData(HttpServletRequest request) throws Exception {
    		Map<String, Collection<Month>> reference = new HashMap<String, Collection<Month>>();
    		Collection<Month> months = new ArrayList<Month>();
    		months.add(new Month(1, "Jan"));
    		months.add(new Month(2, "Feb"));
    		months.add(new Month(3, "Mar"));
    		months.add(new Month(4, "Apr"));
    		months.add(new Month(5, "May"));
    		reference.put("months", months);
    		return reference;
    	}
    Any ideas on what I'm doing wrong?

    Thanks
Working...
X