1.@RequestParam

 

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

 


2.@PathVariable

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

 

@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     }  

 

 

 

4.Request对象

 

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

 

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2022-02-15
  • 2021-11-08
  • 2022-12-23
  • 2021-10-03
  • 2021-05-27
猜你喜欢
  • 2022-01-06
  • 2021-12-19
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案