mercredi 18 mars 2015

How to bind list (in list) binding to Spring MVC?

I have 3 model classes for binding.



class FormBean {
private String a;
private List<A> aList;

//.. get/set

}


class A {
private String aname;
List<B> bList;

// get/set

}

class B {
private String name;
private String id;
// get/set
..
}


And Here is my Controller



public ModelAndView controlMethod (@ModelAttribute FormBean param) {

...
}


==============


And the client-side,


The codes that I made like this.



<form id="userInsert" name="userInsert" method="post" enctype="multipart/form-data" >

<input type="text" name="aList[0].bList[0].name" value="aaa"/>
<input type="text" name="aList[0].bList[1].name" value="aaa1"/>
<input type="text" name="aList[0].bList[2].name" value="aaa2"/>


<input type="text" name="aList[1].bList[0].name" value="aaa3"/>

</form>


===============


But


It's not working well.


But when I request like this.



<input type="text" name="aList[0].aname" value="aaa"/>


then , it's working well..


I want to know what is problem.. and What should I do?


Or It can bind or not.


Regards.


Aucun commentaire:

Enregistrer un commentaire