@RequestMapping(value = "/form/test" ) public ModelAndView totest(HttpServletRequest request,HttpServletResponse response, TextLoginForm form) { String forwardString = "test"; Map<String, Object> model = new HashMap<String, Object>(); try { form.setName("名字123123"); form.setPassword("密码"); model.put("appli", form); } catch (Exception e) { forwardString = "msg"; } return new ModelAndView(forwardString,model); }
ModelAndView 配置后,controller方法
在controller中,使用 ModelAndView 来返回页面,代码如下。