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"; } }
原文地址:https://www.cnblogs.com/loaderman/p/10063307.html
时间: 2024-10-13 04:14:25