检查 sendRedirect 方法的行为更改

此规则将标记对 javax.servlet.http.HttpServletResponse.sendRedirect(String) 方法的引用,因为在 Servlet 3.1 实现与 Servlet 3.0 实现中,相对 URL 的缺省行为会有所不同。Servlet 3.1 的行为会与将 Servlet 3.0 com.ibm.ws.webcontainer.RedirectWithPathInfo 属性设置为 true 时的行为一致,并且将在 Servlet 3.1 实现中忽略该属性。

在 Servlet 3.1 中,如果相对位置不含前导“/”,那么容器会将该位置解释为相对于当前请求 URI。如果相对位置含有前导“/”,那么容器会将该位置解释为相对于 servlet 容器根目录。

例如,如果应用程序提供的重定向位置为 folder/default.jsp(不含前导“/”),并且入站请求 URL 为 http://host:port/context_root/extraFolderhttp://host:port/context_root/extraFolder/,那么在 Servlet 3.1 中,请求会重定向到 http://host:port/context_root/extraFolder/folder/default.jsp(这相对于当前请求 URI)。在 Servlet 3.0 中,请求会重定向到 http://host:port/context_root/folder/default.jsp,除非将 com.ibm.ws.webcontainer.RedirectWithPathInfo 属性设置为 true

有关此方法的更多信息,请参阅 Interface HttpServletResponse

有关 Servlet 3.1 行为更改的更多信息,请参阅以下资源:Servlet 3.1 behavior changes