在業務控制方法中寫入User,Admin多個模型收集參數
阿新 • • 發佈:2018-12-04
code prot style servle EDA dmi simple register ping
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"; } }
在業務控制方法中寫入User,Admin多個模型收集參數