Fork me on GitHub

request.getAttribute( "result");和request.setAttribute("result",username);

request.setAttribute("result",username);
在request对象中加入名为result的属性并附值为username,因为request对象是可以更改的,你可以
在同一个请求中象这样访问这个属性。

虽然类似session,但与session是有所区别的,request.setAttribute设置的属性只能在当前
request只使用,比如你在Action中设置result属性,需要到jsp页面中读取:
request.setAttribute("result",username);
requests.getRequestDispatcher("result.jsp").forward(request, response);
jsp页面获取该值:
request.getAttribute( "result");

因为一同将当前action的request与response对象都发送过来,相当于直接操作自身页面。


request.setAttribute("result",username);
request.getRequestDispatcher("result.jsp").forward(request,response);
requset.getAttribute("result");

posted @ 2015-09-30 17:20  ZZZZW  阅读(347)  评论(0编辑  收藏  举报
AmazingCounters.com