我有一个servlet,它完成所有后端提取并传递数据以呈现jsp。
request.setAttribute("name", "ASDADAS");
request.getRequestDispatcher("/home.jsp").forward(request, response);
在我的home.jsp中,我将值称为
<%= request.getAttribute("name")%>
但是我仍然收到下面的错误
java.io.IOException: Error - getOutputStream() called on a request that has already returned a Writer - enable debug logging on com.isomorphic.servlet.ProxyHttpServletResponse to see a stack trace of the previous caller.
答案 0 :(得分:0)
更好的使用方式
response.sendRedirect(“ / home.jsp”);
它将正常工作
答案 1 :(得分:0)
更好的使用方式
response.sendRedirect(“ / home.jsp”);
它将正常工作
//System.out.println("username"+request.getParameter("username")+"password"+request.getParameter("password"));
request.setAttribute("username", request.getParameter("username"));
RequestDispatcher rd = request.getRequestDispatcher("home.jsp");
rd.forward(request, response);