I am developping a Struts2 application.
I get stucked on this error when posting a form : HTTP 400 State - The request contains invalid parameters
(translated from french).
The form I am using is created from a TreeMap, with BigDecimals for values :
private TreeMap<Integer, BigDecimal> myTreeMap;
In ftl :
<#list model.myTreeMap?keys as key>
<tr>
<td> ${key} </td>
<td> <@s.textfield name="model.myTreeMap[${key}]" value="${model.myTreeMap.get(key)}" maxlength=3 /> </td>
</tr>
</#list>
The problem is, it feels like OGNL is treating the values as Integer, not BigDecimal. Indeed, when going into debug inside the TreeMap setter, I get this error :
ognl.noconversionpossible
I have seen this error before concerning dates, and what I did was creating a custom converter.
But this time the problem seems a bit different. Indeed, if I do not use a TreeMap
, but just a single BigDecimal
in the form, then struts manages to populate correctly my Java Object.
So my questions are :
- Do
TreeMap
-s need special behaviour with Struts2/OGNL? - Do I need to create a custom converter for
BigDecimal
orTreeMap
, or something else?