问题
I am using setHeader()
method to refresh a JSP page as shown below
response.setHeader("Refresh", "5; URL=passDebitCard.jsp");
Now I want to send parameters to this passDebitCard.jsp after refreshing for 5 seconds How can I do that?
回答1:
You can append GET
parameters to the URL like this :
response.setHeader("Refresh", "5; URL=passDebitCard.jsp?param1=test1¶m2=test2");
You should also put an absolute path to this URL as a good practice, like this :
response.setHeader("Refresh", "5; URL=" + request.contextPath + "/passDebitCard.jsp?param1=test1¶m2=test2");
so you won't have path problem even if the previous page is moved or different.
来源:https://stackoverflow.com/questions/16782263/passing-parameters-when-setting-the-refresh-http-header-with-setheader-method