java - 为什么 Servlet 中的重定向要求是绝对的?

标签 java url servlets redirect absolute

谁能告诉我为什么 servlet 中的重定向必须是绝对的?我找到的所有引用资料都告诉我它们必须是绝对的。

来自规范:

The sendRedirect method will set the appropriate headers and content body to redirect the client to a different URL. It is legal to call this method with a relative URL path, however the underlying container must translate the relative path to a fully qualified URL for transmission back to the client. If a partial URL is given and, for whatever reason, cannot be converted into a valid URL, then this method must throw an IllegalArgumentException.

最佳答案

Section 14.30 of RFC 2616 (HTTP/1.1,自已取代)Location header 中强制使用绝对 URL,用于指示重定向的“位置”。在最新版本的规范中,这一点已经放宽,但 Servlet 规范仍然需要向后兼容的行为。

关于java - 为什么 Servlet 中的重定向要求是绝对的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34219296/

相关文章:

java - Libgdx I18NBundle,无法显示斯堪的纳维亚字母

java - 找不到类 : org. glassfish.jersey.servlet.ServletContainer

jsp - 我的主机将 java web 文件显示为原始文件

php - 在页面之间保存 URL 参数?

.htaccess 从 URL + 目录中删除 WWW

javascript - angular.js 更改 url 而不调用 Controller

java - 复制 HttpServletRequest 并发送到另一台服务器?

java - 同步速度与正常速度

java - eclipse java声明快捷方式是什么?

java - Apache commons-collections的synchronizedList()和java.util.Collections.synchronizedList()之间的区别