我有一个 servlet A,我在 HTTP 响应中设置了一个标头:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userName=request.getParameter("userName");
String newUrl = "http://somehost:port/ServletB";
response.addHeader("REMOTE_USER", userName);
response.sendRedirect(newUrl);
}
现在在 servlet B中,我试图获取在 servlet A中设置的标头值:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userid = request.getHeader("REMOTE_USER");
}
但是这里userid的值是null
. 请让我知道我在这里缺少什么。