SpringMVC核心技术---转发和重定向

@Controller
public class Mycontroller {
    //转发
    @RequestMapping("/adduser")
    public String add(HttpServletRequest request){
        request.setAttribute("happy","aa");
        return "/listuser";
    }

    @RequestMapping("/listuser")
    public String list(){
        return "/list.jsp";
    }

    //重定向
    @RequestMapping("/adduser2")
    public String add2(HttpServletRequest request){
        request.setAttribute("happy","aaa");
        return "redirect:/listuser";
    }

    @RequestMapping("/listuser2")
    public String list2(){
        return "redirect:/list.jsp";
    }

}

 

posted @ 2017-08-21 08:55  <烟花易冷>  阅读(114)  评论(0编辑  收藏  举报