---
title: SpirngBoot重定向到其它系统的几种方式
date: 2019-02-13 11:22:44
categories: SpringBoot
tags:
- spring
- response
- 重定向
- boot
- 其它系统
- redirect
- ModelAndView
- void
---
- 一般的String型返回值
@RequestMapping("/haha")
public String haha(HttpServletResponse response){
System.out.println("redirect");
return "redirect:http://www.baidu.com";
}
- void型返回值
@RequestMapping("/gaga")
public void gaga(HttpServletResponse response) throws IOException {
response.sendRedirect("http://www.baidu.com");
}
- ModelAndView型返回值
@RequestMapping("/hehe")
public ModelAndView hehe(ModelAndView mv, HttpServletRequest request){
return new ModelAndView("redirect:http://www.baidu.com");
}