JSP IE 中的页面未收到 POST 参数。在 Chrome 工作
JSP page in IE not receiving POST parameters. Works in Chrome
一个非常简单的设置。
HTML形式
<form id="ChromeEmailForm" method="POST" action="ChromeEmail.jsp" target="ChromeEmailWindow" >
<input type="hidden" name="emailSubject" value="something" />
<input type="hidden" name="htmlBody" value="something" />
</form>
JS 提交:
document.getElementById('ChromeEmailForm').submit();
并在 JSP 中检索使用:
<%=request.getParameter("emailSubject")%>
在 Chrome 中工作正常,但 returns "null" 在 ChromeEmail.jsp 页面的 IE (11) 中。页面在两种浏览器中返回。
尝试添加 JSP 以强制编码,但没有效果:
<%@ page contentType="text/html; charset=utf-8"%>
<%request.setCharacterEncoding("UTF-8");%>
这是 IE 的已知功能吗?
事实证明,这个 是 一个 IE 功能,如下所述:
Challenge-Response Authentication and Zero-Length Posts
来自文章:
For performance reasons, Internet Explorer does not immediately transmit a POST body if it expects to immediately receive a HTTP/401 response with a challenge for credentials. Without this optimization, IE would be forced to reupload the (potentially large) POST body multiple times, wasting bandwidth.
这解释了为什么 POST 数据在身份验证站点中丢失。
一个非常简单的设置。 HTML形式
<form id="ChromeEmailForm" method="POST" action="ChromeEmail.jsp" target="ChromeEmailWindow" >
<input type="hidden" name="emailSubject" value="something" />
<input type="hidden" name="htmlBody" value="something" />
</form>
JS 提交:
document.getElementById('ChromeEmailForm').submit();
并在 JSP 中检索使用:
<%=request.getParameter("emailSubject")%>
在 Chrome 中工作正常,但 returns "null" 在 ChromeEmail.jsp 页面的 IE (11) 中。页面在两种浏览器中返回。
尝试添加 JSP 以强制编码,但没有效果:
<%@ page contentType="text/html; charset=utf-8"%>
<%request.setCharacterEncoding("UTF-8");%>
这是 IE 的已知功能吗?
事实证明,这个 是 一个 IE 功能,如下所述: Challenge-Response Authentication and Zero-Length Posts
来自文章:
For performance reasons, Internet Explorer does not immediately transmit a POST body if it expects to immediately receive a HTTP/401 response with a challenge for credentials. Without this optimization, IE would be forced to reupload the (potentially large) POST body multiple times, wasting bandwidth.
这解释了为什么 POST 数据在身份验证站点中丢失。