Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Task #662740 » 新建文本文档.txt

家豪 曹, 2017-06-15 12:25 AM

 
1
Controller??:Controller?㸺??????ҵ??ģ?????̵Ŀ??ƣ??ڴ˲?????Ҫ????Serice??Ľӿ???????ҵ?????̣????Ƶ?????Ҳͬ??????Spring???????ļ???????У???Ծ????ҵ?????̣????в?ͬ?Ŀ??????????Ǿ??????ƹ????п??Խ????̽??г?????ɣ???Ƴ??????ظ????õ??ӵ?Ԫ????ģ?飬????????ʹ????ṹ?????????Ҳ???????˴???????   
2
RequestMapping(value = "/show2?userId",method = {RequestMethod.GET})
3
    public String showUser2(@RequestParam("userId")Integer userId,Model model){
4
        User user = userService.getUserById(userId);
5
        model.addAttribute(user);
6
        return "showUser";
7
    }
8
ʹ??HttpServletRequest
9
 @RequestMapping("show1")
10
    public String showUser(HttpServletRequest request){
11
        int userId = Integer.parseInt(request.getParameter("userId"));
12
        User user = userService.getUserById(userId);
13
        request.setAttribute("user", user);
14
        return "showUser";
15
    }
16
ʹ??MAP
17
 @RequestMapping(value = "/show3/{userId}",method = RequestMethod.GET)
18
    public String showUser3(@PathVariable("userId") Integer userId,Map<String,Object> model){
19
        User user = userService.getUserById(userId);
20
        model.put("user", user);
21
        return "showUser";
22
    }
    (1-1/1)