码迷,mamicode.com
首页 > 其他好文 > 详细

转发和重定向

时间:2018-01-15 22:33:15      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:ring   pos   except   span   默认   hid   lap   map   font   

1)转发 (默认)

   return "逻辑视图";

2)重定向

return "redirect:地址" //到请求地址

 

技术分享图片
 1 @RequestMapping("/modify/{id}")
 2     public String getUserById(@PathVariable String id,Model model)
 3             throws ServletException, IOException {
 4         User user = userService.getUserById(id);
 5         model.addAttribute("user", user);
 6         return "usermodify";
 7     }
 8     
 9     @RequestMapping("/modifyexe")
10     public String modify(User user,HttpSession session)
11             throws ServletException, IOException {
12         user.setModifyBy(((User)session.getAttribute(Constants.USER_SESSION)).getId());
13         user.setModifyDate(new Date());
14         if(userService.modify(user)){
15             return "redirect:query";
16         }else{
17             return "usermodify";
18         }
19     }
示例

 

转发和重定向

标签:ring   pos   except   span   默认   hid   lap   map   font   

原文地址:https://www.cnblogs.com/yang82/p/8289717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!