When i am keeping two inputs name same in jsp. I want they should be come to controller in two different objects. @ModelAttribut
@RequestMapping(value = "/addUser", method = RequestMethod.POST)
public String addAdvertiser(@ModelAttribute("userInfoEntity") UserInfoEntity userInfoEntity,@ModelAttribute("addressEntity") AddressEntity personalAddress,@ModelAttribute("addressEntity") AddressEntity billingAddress){
// save this two address to my userInfo Entity
// here i had one to many relationaship. from UserInfoEntity to AddressEntity
}
My JSP is as follows:
Personal Address
<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>
Billing Address
<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>
Please tell me the solution that how can i send two objects of same AddressEntity from jsp to controller keeping the same value for attribute "name" of input type.
In the given senario i am getting the object but it includes values of both address by ","(comma) seperated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…