Accept parameters for the time two ways
method one
@InitBinder public void of an initBinder (ServletRequestDatabinder Binder) { // long as the page data from the format of yyyy-MM-dd will be converted to the Date type binder.registerCustomEditor (Date. Class , new new the CustomDateEditor ( new new the SimpleDateFormat ( "the MM-YYYY -dd " ), to true )); } @RequestMapping ( " date.do " ) public String acceptDate (a Date DATE) { System.out.println (DATE); return " index " ; }
Method Two
@RequestMapping("test1.do") public ModelAndView test1() { ModelAndView m=new ModelAndView("test"); m.addObject("name", "李四"); return m; } @RequestMapping("test2.do") public String test2(Map<String,String> m) { m.put("name", "王五"); return "test"; } @RequestMapping("test3.do" m.addAttribute (test3 String (Model m) {Public) "name", "赵六"); return "test"; } @RequestMapping("test4.do") public String test4(HttpSession session) { session.setAttribute("name", "王八"); return "test"; }
#########################################
##############################################
##################################
Redirect
@RequestMapping("test6.do") public String test6() { return "redirect:SpringMVC_02/login.jsp"; }
#############################################
SpringMVC complete ajax
- Join jackson jar package. Springmvc.
- The method of adding in response @ResponseBody: json object into the java object.
- The return value method may be a collection of strings objects.
There will be Chinese garbage problem