在业务控制方法中写入User,Admin多个模型收集参数

1)  可以在业务控制方法中书写1个模型来收集客户端的参数

2)  模型中的属性名必须和客户端参数名一一对应

3)  这里说的模型不是Model对象,Model是向视图中封装的数据

@Controller
@RequestMapping(value = "/user")
public class UserAction {
    @InitBinder
    protected void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {
        binder.registerCustomEditor(
                Date.class, 
                new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
    }
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String add(User user,Model model) throws Exception {
        System.out.println("HelloAction::add()::POST");
        model.addAttribute("user",user);
        return "/register.jsp";
    }
}

 

posted on 2018-12-04 11:58  LoaderMan  阅读(292)  评论(0编辑  收藏  举报

导航