SpirngBoot重定向到其它系统的几种方式

  • A+
所属分类:SpringBoot
  • 一般的String型返回值
@RequestMapping("/haha")
public String  haha(HttpServletResponse response){
    System.out.println("redirect");
    return "redirect:http://www.baidu.com";
}
@RequestMapping("/gaga")
    public void  gaga(HttpServletResponse response) throws IOException {
        response.sendRedirect("http://www.baidu.com");
    }
@RequestMapping("/hehe")
    public ModelAndView hehe(ModelAndView mv, HttpServletRequest request){
      return new ModelAndView("redirect:http://www.baidu.com");
    }
ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: