SpringMVC注解式 转发与重定向

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

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

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

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

}
 
  
 
  
重定向关键字:redirect

你可能感兴趣的:(SpringMVC注解式 转发与重定向)