我认为我的语法是正确的,但是我的表单支持对象中的列表没有被填充。看起来列表本身正在制作中,只是它没有元素。其他属性正在按预期填充。有任何想法吗?
JSP:
<form:form method="post" commandName="addReminder">
Reminder Name <input type='text' name='reminderName' placeholder="Reminder Name"> <br />
Date <input type='text' name='date' placeholder="1/05/2013"> <br />
Time <input type='text' name='time' placeholder="4:00 PM"> <br />
Time Zone <input type='text' name='timeZone' placeholder="EDT"> <br />
<br />
Contacts <input type='text' path="contacts[0].phoneNumber" placeholder="Name"> <br />
<input type='text' path="contacts[1].phoneNumber" placeholder="Name"> <br />
<input type="submit" value = "Add Reminder">
</form:form>
控制器:
@RequestMapping(value = "/AddAReminder", method = RequestMethod.POST)
public String addReminder(@ModelAttribute("addReminder") AddReminder reminder, BindingResult result)
{
//does stuff with the data from the form backing object
return "Add A Reminder";
}
表单支持对象:
public class AddReminder
{
private String reminderName;
private String date;
private String time;
private String timeZone;
private ArrayList<Contact> contacts = new ArrayList<Contact>();
private String sentFrom;
private String message;
private String provider;
//getters and setters
联系对象:
public class Contact
{
private String firstName;
private String lastName;
private String phoneNumber;
private String provider;
//getters and setters