【发布时间】:2019-02-11 16:02:57
【问题描述】:
我想将 URL 放入 GET 请求中,这样我就可以将用户重定向到给定的 URL。
这是我目前的代码:
@RequestMapping(value = { "/mapping/{param1}/{redirectLink}" }, method = { RequestMethod.GET})
public void mapping(HttpServletResponse response, @PathVariable("param1") String param1, @PathVariable("redirectLink") String redirectLink) throws IOException {
// code i wanna run
response.sendRedirect(backLink);
}
我用来 GET 的示例 url - http://localhost:8080/app/controller/redirectionTest/1234/http://localhost:3000/main
因此,当我调用 GET 方法时,我想运行一些代码,然后将其重定向到 http://localhost:3000/main,但 URL 中有斜杠,因此无法实现。
【问题讨论】:
-
为什么不使用查询参数呢?
-
任何方式都可以,只要你用一个例子解释我如何最好地做到这一点。