springboot跳转外部链接

@Controller
public class TestController {

}

1、使用ModelAndView

@RequestMapping("redirect")
public ModelAndView redirect(){
    return new ModelAndView("redirect:http://www.baidu.com");
}

2、使用SpringMVC

@RequestMapping("redirect2")
public String redirect(){
    return"redirect:http://www.baidu.com";
}

3、使用HttpServletResponse

@RequestMapping("/send")
public void sendInfoToWeiXin(HttpServletResponse response){
    try {
        response.sendRedirect("http://www.baidu.com");
    } catch (IOException e) {
        e.printStackTrace();
    }
}

版权声明:本文为embelfe_segge原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。