Announcement Announcement Module
No announcement yet.
Binding HTTP form fields onto model of type Map Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding HTTP form fields onto model of type Map


    We use Spring 2.5.5 and WebFlow 2.0 for our web application. When mapping http form field values onto the underlying model object of type HashMap, the application aborts with a NullPointerException, although mapping onto Maps is supported by MVC/WebFlow.

    We assume that above behaviour is caused by a bug in the Spring Binding module. Please see the following discussion.

    Our jsp form consists of a single input field. Basically the form looks as follows:

    <spring:bind path="model.personName">
    <input type="text" name="${status.expression}" value="${status.value}">

    Our underlying model is of type HashMap and contains (among other entries) the entry "personName" -> "Firstname Lastname".

    When a user enters above jsp view, a NullPointerException is thrown when the bind tag tries to infer the converter for the displaying field. Obviously, some component is not able to infer the converter for a specific Map element.

    I debugged through the WebFlow and Spring Core and found out that the problem seems to reside in the org.springframework.webflow.mvc.view.BindingModel class. The NullPointerExcpetion arises in the getConverter depicted below. fieldExpression.getValueType(boundObject) answers null and hence, valueType.isArray() in the subsequent if clause fails.

    private ConversionExecutor getConverter(Expression fieldExpression) {
    if (conversionService != null) {
    Class valueType = fieldExpression.getValueType(boundObject);

    if (valueType.isArray()
    || Collection.class.isAssignableFrom(valueType)
    || Map.class.isAssignableFrom(valueType)) {
    return null;


    Does anyone has the same problem encountered?
    Is above behavior a bug or do we do something wrong?

    Thx a lot for feedback.