[英]Redirect welcome page to a page in another domain in servlet container?
[英]Servlet send redirect to welcome page?
如何強制Servlet重定向到歡迎頁面而不必指定確切的路徑? 就像改變最上層的路徑一樣:
response.sendRedirect("/");
哪個顯然不起作用。
response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/"));
如果要支持禁用cookie支持的瀏覽器的會話跟蹤(即使用URL重寫),則必須調用encodeRedirectURL。
感謝上面的Michael-O,以下解決方案:
response.sendRedirect(request.getContextPath());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.