1、提交数据的处理(1)提交的域名称和处理方法的参数一致即可提交的数据:处理方法:@RequestMapping("/hello")publicStringhello(Stringname){System
println("name
"+name);return"index
jsp";}结果:(2)提交的域名称和参数名不一致提交的数据:处理方法:@RequestMapping("/hello")publicStringhello(@RequestParam("uname")Stringname){System
println("name
"+name);return"index
jsp";}结果:(3)提交的是一个对象,要求提交的表单域名和对象的属性名一致,参数使用对象作为参数即可提交的数据:处理方法:@RequestMapping("/user")publicStringuser(Useruser){System
println(user);return"index
jsp";}}结果:实体类:publicclassUser{privateintid;privateStringname;privateStringpwd;get,set…@OverridepublicStringtoString(){return"User[id="+id+",name="+name+",pwd="+pwd+"]";}}2、将数据显示到UI层(1)通过ModelAndView---需要通过视图解析器@RequestMapping("/hello")publicModelAndViewhello(HttpServletRequestrequest,HttpServletResponseresponse){//相当于request
setAtttibute("ms