在变量search_for中,我得到了我正在搜索的值的字符串值。但是我无法通过RequestDispatcher将它传递给jsp。我做错了什么?
RequestDispatcher rd = request.getRequestDispatcher("my.jsp?search_for");
答案 0 :(得分:3)
Soution 1:
request.setAttribute("paramName", search_for);
RequestDispatcher rd = request.getRequestDispatcher("my.jsp");
rd.forward(request, response);
或强>
Soution 2:
RequestDispatcher rd = request.getRequestDispatcher("my.jsp?paramName="+search_for);
rd.forward(request, response);