且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AJAX - 获取重定向后响应URL

更新时间:2022-05-04 05:17:56

在一个Java过滤器设置响应头位置解决了这个。

Solved this by setting the response header "Location" in a Java Filter.

  HttpServletRequest httpRequest = (HttpServletRequest) request;
  HttpServletResponse httpResponse = (HttpServletResponse) response;
  String path = httpRequest.getRequestURI();
  httpResponse.setHeader("Location", path);

在JavaScript中,我可以再使用

In JavaScript I could then use

  XMLHttpRequest.getResponseHeader("Location")

希望这不会造成任何不可预见的问题。 :P

Hopefully this won't cause any unforeseen problems. :P

如果任何人有一个简单的解决方案,虽然我想看到的。

If anyone else have an easier solution though I'd like to see it.