Spring中的Path属性
任何人都可以解释一下path属性如何在Spring中将对象从html表单绑定到Java类。 我是spring网页框架的新手,请帮忙。
长话短说,使用java bean约定将path属性绑定到java属性中。 例如,以下表格:
Name: Cool?:
并遵循控制器处理方法:
@RequestMapping(...) public String updateStudent(@ModelAttribute("theStudent") Student student) { // ... }
如果使用以下属性定义Student类,将自动绑定:
public class Student { private String name; public String getName() { return this.name; } public void setName(String name) { this.name = name; } private boolean cool; public boolean isCool() { return this.cool; } public void setCool(boolean cool) { this.cool = cool; } }
有关JavaBeans会话的更多信息,请参阅规范文档的第8.3节 。