Spring Binding Problem

I have some objects like the two below

public class SavedSearch { String title; ArrayList<SearchParameters> params; } public class SearchParameter { String field; int operator; String match; } 

On the JSP page in the input form, I use

 <input type="text" name="title"> 

and when I break the point inside the FormController, the SavedSearch object has a header filled out.

But ArrayList is always empty. This is not a Spring bug that he cannot read, but how to indicate that a field, operator, and match are part of the parameters? I tried calling them paramsField, paramsOperator, paramsMatch, but no luck.

I know this is not a difficult question, but I'm a bit puzzled.

+4
source share
1 answer

to bind the list, you should use a special wrapper instead of ArrayList: AutoPopulatingList from Spring or LazyList from the Apache community Commons collections.

a few examples:

using LazyList

using AutoPopulationList

+2
source

All Articles