gpt4 book ai didi

java - 是否可以在不调用response.sendRedirect(...)方法的情况下发送重定向?

转载 作者:行者123 更新时间:2023-12-01 18:37:23 26 4
gpt4 key购买 nike

在 servlet 中,我希望客户端浏览器重定向到新的 URL,response 对象已通过 lib 将带有 Location 的 header 设置为新的 url,但是我无法在代码中获取重定向网址(没有response.getHeader(...),所以我的问题是,是否可以在不调用response.sendRedirect(...)方法的情况下发送重定向?如何?

最佳答案

您可以在响应正文中发送重定向。

类似...

response.getWriter().println("<html><head><META http-equiv=\"refresh\" content=\"0;URL=http://google.com\"></head></html>\");

关于java - 是否可以在不调用response.sendRedirect(...)方法的情况下发送重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21348016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com