标签:类型 tab nbsp attr omd form 返回 set test
接受参数为时间的两种方法
方法一
@InitBinder public void initBinder(ServletRequestDataBinder binder){ //只要网页中传来的数据格式为yyyy-MM-dd 就会转化为Date类型 binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); } @RequestMapping("date.do") public String acceptDate(Date date) { System.out.println(date); return "index"; }
方法二


@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")
public String test3(Model m) {
m.addAttribute("name", "赵六");
return "test";
}
@RequestMapping("test4.do")
public String test4(HttpSession session) {
session.setAttribute("name", "王八");
return "test";
}
#########################################

##############################################

##################################
重定向
@RequestMapping("test6.do")
public String test6() {
return "redirect:SpringMVC_02/login.jsp";
}
#############################################
SpringMVC完成ajax

还会出现中文乱码问题
标签:类型 tab nbsp attr omd form 返回 set test
原文地址:https://www.cnblogs.com/accc111/p/11456340.html