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对象都发送过来,相当于直接操作自身页面。

相关文章:

  • 2021-10-08
  • 2021-05-17
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-06-10
猜你喜欢
  • 2022-12-23
  • 2021-10-21
  • 2021-05-21
  • 2022-12-23
  • 2021-07-15
  • 2021-08-18
相关资源
相似解决方案