如何在重定向到另一个 URL 时传递 URL 参数?

How to pass URL parameters when redirecting to another URL?

调用页面 (www.dasinfobuch.de/links/Wizz) 时,我正在使用此 html 代码重定向到另一个 URL:

<head>
  <meta http-equiv="refresh" content="0; URL=http://52.28.104.181:8080/Wizard/Wizz">
</head>

但是,当我使用 URL 参数时,例如

www.dasinfobuch.de/links/Wizz?template=test

参数未传递到重定向页面。有没有办法做到这一点(最好是普通的HTML)? (我是 Web 编程的新手。)

仅使用模仿 non-standard Refresh HTTP header field 的元元素是不可能的。当然还有其他方法。

如果你有类似预处理器的东西,你可以将请求传递给 HTML,像这样:

<meta http-equiv="refresh"
      content="0; URL=http://52.28.104.181:8080/Wizard/Wizz?template=<%
           out.print(request.getParameter("template")) %>">

另一种(客户端)方式是使用 JavaScript:

重定向
document.location.href = 'http://52.28.104.181:8080/Wizard/Wizz' + document.location.search;

请注意,这将继承整个查询字符串,而不仅仅是 template 参数及其参数。如果这是一个问题,很容易只从 location.search.

中获取所需的字符串