Servlet or JSP - How do I redirect a post request without data loss

后端 未结 1 878
走了就别回头了
走了就别回头了 2021-01-26 03:43

My server moved to a new location and I need to redirect requests to the new location. If I use HttpServletResponse.sendRedirect(new_server_location), I am losing all the POST d

相关标签:
1条回答
  • 2021-01-26 03:57

    The sendRedirect() is by default a HTTP 302 redirect. You want to send a HTTP 307 redirect instead.

    response.setStatus(307);
    response.setHeader("Location", new_server_location);
    

    This only issues a default browser warning on most browsers.

    0 讨论(0)
提交回复
热议问题