Struts中JSP到Action過程中數組的投射
Jsp
<div>
<input type="hidden" name="stulst.name" value="xy"/>
<input type="hidden" name="stulst.name" value="xy1"/>
<input type="hidden" name="stulst.name" value="xy2"/>
</div>
這就表明,有三條不同的記錄。
Action
public List<Student> stulst;
...................................................
public Stirng tosave()
{
for(Student s : stulst)
{
name屬性已經接收到了,就不要再設置了
s.setAge(10);
s.setPhone("111");
stuService.save(s);
}
return "tosave";
}
以上是簡單的情況,關於struts如何接受數組的詳細文章,請參見我的
《struts中接收數組的表單和ajax兩種形式》https://blog.csdn.net/woshixuye/article/details/7969496
最後更新:2017-04-02 22:16:21