我想将对象列表从 jsp 发送到控制器。
实际上我有用户实体,它与地址实体有一对多的关系。我的jsp如下:
<div class="label"><b>First Name :</b></div>
<div class="leftSide"><input type="text" name="firstName" class="textBox" style="width:250px;" /></div>
<div class="clr ht5"></div>
<div class="label"><b>Company :</b></div>
<div class="leftSide"><input type="text" name="company" class="textBox" style="width:250px;" /></div>
<div class="clr ht5"></div>
</div>
<div class="rightHalfColumn">
<div class="label"><b>Last Name :</b></div>
<div class="leftSide"><input type="text" name="lastName" class="textBox" style="width:250px;" /></div>
<div class="clr ht5"></div>
<div class="label"><b>Email Address :</b></div>
<div class="leftSide"><input type="text" name="email" class="textBox" style="width:250px;" /></div>
<div class="clr ht5"></div>
Address 1
<div class="label"><b>Address 1 :</b></div>
<div class="leftSide"><input type="text" name="address1" class="textBox" style="width:250px;" /></div>
<div class="label"><b>City :</b></div>
<div class="leftSide"><input type="text" name="city" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Zipcode :</b></div>
<div class="leftSide"><input type="text" name="zipcode" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Address 2 :</b></div>
<div class="leftSide"><input type="text" name="address2" class="textBox" style="width:250px;" /></div>
<div class="label"><b>State :</b></div>
<div class="leftSide"><input type="text" name="state" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Phone :</b></div>
<div class="leftSide"><input type="text" name="phone" class="textBox" style="width:250px;" /></div>
Address 2
<div class="label"><b>Address 1 :</b></div>
<div class="leftSide"><input type="text" name="address1" class="textBox" style="width:250px;" /></div>
<div class="label"><b>City :</b></div>
<div class="leftSide"><input type="text" name="city" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Zipcode :</b></div>
<div class="leftSide"><input type="text" name="zipcode" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Address 2 :</b></div>
<div class="leftSide"><input type="text" name="address2" class="textBox" style="width:250px;" /></div>
<div class="label"><b>State :</b></div>
<div class="leftSide"><input type="text" name="state" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Phone :</b></div>
<div class="leftSide"><input type="text" name="phone" class="textBox" style="width:250px;" /></div>
Address 3
<div class="label"><b>Address 1 :</b></div>
<div class="leftSide"><input type="text" name="address1" class="textBox" style="width:250px;" /></div>
<div class="label"><b>City :</b></div>
<div class="leftSide"><input type="text" name="city" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Zipcode :</b></div>
<div class="leftSide"><input type="text" name="zipcode" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Address 2 :</b></div>
<div class="leftSide"><input type="text" name="address2" class="textBox" style="width:250px;" /></div>
<div class="label"><b>State :</b></div>
<div class="leftSide"><input type="text" name="state" class="textBox" style="width:250px;" /></div>
<div class="label"><b>Phone :</b></div>
<div class="leftSide"><input type="text" name="phone" class="textBox" style="width:250px;" /></div>
这里我有三个地址。地址 1、地址 2 和地址 3
现在我得到了用户信息,@ModelAttribut("user") User user
但我没有得到地址列表user.getAddress();
。它返回地址列表的“[]”空值。我如何从 jsp 到控制器中获取此地址对象列表。
任何人都可以帮助我吗..