@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("orden", 11);
System.out.println("ord "+request.getParameter("orden"));//returns null
request.getRequestDispatcher("/view/a.jsp").forward(request, response);
}
//Why does this happen?
在我的jsp中是相同的result = null
答案 0 :(得分:1)
您正在设置attribute
并尝试获取parameter
request.setAttribute("orden", 11);
request.getAttribute("orden");
答案 1 :(得分:0)
属性和参数是不同的东西。在设置属性时,请使用getAttribute()获取值。
System.out.println("ord "+request.getAtribute("orden"));