2014년 11월 4일 화요일

[Spring] @ModelAttribute를 배열(ArrayList)로 받아서 사용하기

public class TestVo {

 //자기 자신을 참조하여 리스트를 리턴하도록 한다.
 private List<TestVo> testList;
 private String key;
 private String name;
 private String phone;
 private Date birth;
 private int age;
 private boolean married;

 

 public List<TestVo> getTestList() {
  return testList;
 }
 public void setTestList(List<TestVo> testList) {
  this.testList = testList;
 }
 public String getKey() {
  return key;
 }
 public void setKey(String key) {
  this.key = key;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getPhone() {
  return phone;
 }
 public void setPhone(String phone) {
  this.phone = phone;
 }
 public Date getBirth() {
  return birth;
 }
 public void setBirth(Date birth) {
  this.birth = birth;
 }
 public int getAge() {
  return age;
 }
 public void setAge(int age) {
  this.age = age;
 }
 public boolean isMarried() {
  return married;
 }
 public void setMarried(boolean married) {
  this.married = married;
 }
}

 
JSP :
<input name="testList[0].name" />
...
<input name="testList[1].name" />
...


참고 :
http://reikop.tistory.com/16
http://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/

댓글 없음:

댓글 쓰기