Spring framework接收html array element


接收某一個參數的array
in html:
<td><input type="text" name="priority" value="${Bean.priority}"></td>

in spring controller:
@RequestParam(value = "priority", required = true) String priority[]


接收多個參數的array,使用modelAttribute
in html:
<form:form method="post" action="save.html" modelAttribute="contactForm">
<td><input name="contacts[${status.index}].firstname" value="${contact.firstname}"/></td>

in spring controller:
@ModelAttribute("contactForm") ContactForm contactForm
List<Contact> contacts = contactForm.getContacts();


Spring MVC: Multiple Row Form Submit using List of Beans
http://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/

<c:forEach varStatus="status">中 varStatus的属性简介
http://my.oschina.net/xsh1208/blog/179841

留言

這個網誌中的熱門文章

Java Servlet MVC web app

JavaMail透過Gmail寄信發生AuthenticationFailedException錯誤