数据回波
1 .什么是数据回波
提交表单后,如果出现错误,请将刚才提交的数据回显到刚才提交的页面
2.pojo数据回显方法
2.1springmvc默认回显pojo数据
当pojo数据传递给controller方法时,springmvc会自动将pojo数据放入request域中。 key与pojo类型(首字母小写)相同
2.2指定使用@ model attribute将pojo回显到请求页面的key
@ModelAttribute还可以将方法的返回值传递到页面,例如在商品搜索列表页面、按商品类型搜索商品信息、在controller中定义商品类型搜索方法,然后最终将商品类型传递到页面。
//商品分类//itemtypes是最终将方法的返回值放入request的key@modelattribute(itemtypes ) (public MapString,String getItemTypes ) ) MMP itemtypes.put(102,母子); return itemTypes; }页面上可以获得itemTypes数据
商品类型select name=' item type ' c : foreach items=' $ { item types } ' var=' item type ' option value=' item type.key ' $ { }
model.addAttribute (,);
3 .简单类型数据回波
用最简单的方法使用模型