1、表单要求:name的值为所对应的对象的实现值+“.”+属性;
如:
<form action="admin/Category-add" method="post">
<input type="text" name="category.name" />
<textarea rows="5" cols="10" name="category.description"></textarea>
<input type="submit" value="提交"/>
</form>
2、所对应对象(bean)应该有相关的对象的实现,并且包括相应的属性的setter和getter方法。
3、Action应该包括相应属性的实现(必须和1中的实现对象名字一致)
如:
private Category category;
public Category getCategory() {
return category;
}
public CategoryService getCategoryService() {
return categoryService;
}
--------------------------------------------------
通过以上方法,既可以实现对对象的自动装载,不用再像javaweb基础中,获取各个属性值再去一个一个去封装。