ZPY博客

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

---
title: SpirngBoot重定向到其它系统的几种方式
date: 2019-02-13 11:22:44
categories: SpringBoot
tags:
- spring
- response
- 重定向
- boot
- 其它系统
- redirect
- ModelAndView
- void
---

@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");
    }