1.初步配置


        //----------1
@RequestMapping(“/register”)
public ModuleAndView register(){
ModuleAndView mav = new ModuleAndView();
mav.setViewName(“user/register”);
return mav;
}
//-------2
@RequestMapping(“/register”)
public String register(){
return “user/register”;
}
//----------------3
@RequestMapping(“/createUser”)
public ModuleAndView createUser(User user){
ModuleAndView mav = new ModuleAndView();
mav.setViewName(“user/register”);
mav.addObject(“user”,user);
return mav;
}
}
        @RequestMapping(value=”/user”,method=RequestMethod.POST,params=”userId”)
Public String test(@RequestParam(“userId”) String userId){
//Public String test(@RequestParam(value=“userId”,required=false)String userId){
//do sth
return “user/index”;
}

在容器中显示定义的AnnotationMethodHandlerAdapter会覆盖掉默认的,,所以默认的四个HttpMessageConverter还需重新装配

05-11 22:35