我在myServlet.java的doGet()中写道:
request.setAttribute("a","111");
response.sendRedirect("a.jsp");我在a.jsp中写道:
String aValue="";
if(request.getAttribute("a")!=null){
aValue= String.valueOf(request.getAttribute("a"));
}
out.println(aValue);可request.getAttribute("a")总是取不到值, 是我错误地使用了request.setAttribute()方法吗? 如果想让servlet给jsp页面传一些值应该通过什么方法呢? 谢谢~
request.setAttribute("a","111");
response.sendRedirect("a.jsp");我在a.jsp中写道:
String aValue="";
if(request.getAttribute("a")!=null){
aValue= String.valueOf(request.getAttribute("a"));
}
out.println(aValue);可request.getAttribute("a")总是取不到值, 是我错误地使用了request.setAttribute()方法吗? 如果想让servlet给jsp页面传一些值应该通过什么方法呢? 谢谢~
ServletException, IOException {
doGet(request, response);
}
RequestDispatcher dispatcher=request.getRequestDispatcher("a.jsp");
dispatcher.forward(request,response);