SpringMVC 数据绑定实例详解(4)

@RequestMapping("test.do") public void test(UserMapForm userForm) { for (Map.Entry<String, User> entry : userForm.getUsers().entrySet()) { System.out.println(entry.getKey() + ": " + entry.getValue().getFirstName() + " - " + entry.getValue().getLastName()); } }

  JSP表单代码:

<form action="test.do" method="post"> <table> <thead> <tr> <th>First Name</th> <th>Last Name</th> </tr> </thead> <tfoot> <tr> <td colspan="2"><input type="submit" value="Save" /></td> </tr> </tfoot> <tbody> <tr> <td><input value="aaa" /></td> <td><input value="bbb" /></td> </tr> <tr> <td><input value="ccc" /></td> <td><input value="ddd" /></td> </tr> <tr> <td><input value="eee" /></td> <td><input value="fff" /></td> </tr> </tbody> </table> </form>

打印结果:

x: aaa - bbb y: ccc - ddd z: eee - fff

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjjdw.html