1.@RequestParam


1. @RequestMapping(value = "/xxxx.do")
2. public void create(@RequestParam(value="userName") String userName) throws Exception {
3.
4. }
@RequestMapping(value = "/xxxx.do")
public void create(@RequestParam(value="userName") String userName) throws Exception {

}


2.@PathVariable


1. @RequestMapping(value="/{groupId}.do")
2. public void detail(@PathVariable long groupId){
3. groupRepository.selectOne(groupId);
4. }
@RequestMapping(value="/{groupId}.do")
public void detail(@PathVariable long groupId){
groupRepository.selectOne(groupId);
}

3.@ModelAttribute



1. @RequestMapping(value = "/xxxx.do")
2. public String create(@ModelAttribute User user) throws Exception {
3. userService.insert(user);
4. return "redirect:/user/create.do";
5. }
@RequestMapping(value = "/xxxx.do")
public String create(@ModelAttribute User user) throws Exception {
userService.insert(user);
return "redirect:/user/create.do";
}


4.Request对象


1. public ModelAndView method1(HttpServletRequest request,
2. throws ServletException, IOException {
3. new HashMap();
4. "message", "你调用的是方法1");
5. return new ModelAndView("/index.jsp", "model", model);
6. }




作者:少帅