2

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 :

  1. Do TreeMap-s need special behaviour with Struts2/OGNL?
  2. Do I need to create a custom converter for BigDecimal or TreeMap, or something else?
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
realUser404
  • 2,111
  • 3
  • 20
  • 38

0 Answers0