重定向方式其实挺多的,不过这里只分享一种,参考代码如下:
@GetMapping("/redirect/{id}")
public void redirect(@PathVariable("id") String id, HttpServletResponse resp) throws IOException {
String redirectUri = "http://www.baidu";
resp.sendRedirect(redirectUri);
}
通过以上方式,访问/redirect/{id}接口,就会被重定向到百度。
更多推荐
Spring Boot重定向
发布评论