<a href="<%=basePath %>customer/edit.do?id=${row.cust_id}" >修改</a>提交的url id对应,将后台得到的数据放入model中,后台通过value="${customerById.cust_id }取出数据
@RequestMapping(value="edit.do")
public String edit( Integer id,Model model){
Customer customerById = customerService.selectCustomerById(id);
model.addAttribute("customerById", customerById);
return "update";
}
页面中的表单的name名称必须为Customer 这个类中对应的字段名
@RequestMapping(value="update.do")
public String update( Customer customer){
customerService.updateCustomerById(customer);
return "redirect:/customer/list.do";
}
也可以通过ModelAndView实现带参数页面跳转
@RequestMapping(value="login")
public ModelAndView login(){
ModelAndView mav = new ModelAndView();
mav.setViewName("welcome"); //设置跳转页面
mav.addObject("message","hello kitty");
//List
List<String> list = new ArrayList<String>();
list.add("java");
list.add("c++");
list.add("oracle");
mav.addObject("bookList", list);
//Map
Map<String,String> map = new HashMap<String,String>();
map.put("zhangsan", "北京");
map.put("lisi", "上海");
map.put("wangwu", "深圳");
mav.addObject("map",map);
return mav;
}