The issue reported by lis and rosco has a simple cause.
The property path attribute used by the bind tag is just a regular String attribute.
So when the JSP engine processes JSP code like this:
Code:
<spring:bind path="myForm.myObject.mapField[${key}].stringField">
The actual string value received by the BindTag is this:
Code:
myForm.myObject.mapField[1].stringField
The DataBinder/BeanWrapper divide this path in the various components:
myForm, myObject, mapField, [1], stringField (or something similar).
Now, at this point, the "[1]" component is just a regular String. While the expression evaluator of an JSP engine may have more information to infer types, the data binding framework only has a String to work with. Spring simply can't obtain the required type information from a Map instance.
Of course, one workaround would be to amend the databinding code with something like:
Code:
// if the path element is a map ...
if(!map.isEmpty())
{
Class requiredClass = map.keySet().iterator().next().getClass();
// Apply existing binding logic, e.g. call doTypeConversionIfNecessary() etc
}
This smells like a hack, but may be useful for users binding to Map instances with non-String keys.
p.s. It would be a good idea to move this thread to the Web forum