Java_Web_request.setAttribute("result",username);
2015-08-01 02:25
603 查看
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对象都发送过来,相当于直接操作自身页面。
相关文章推荐
- 【Android UI】ListView系列一(基础篇)
- 深入源码解析Android中的Handler,Message,MessageQueue,Looper
- android 各种UI控件的特殊使用方式(不定期更新)
- UIButton简单总结
- hdu 5288 OO’s Sequence
- Packet for query is too large
- mysql异常Packet for query is too large(mysql写入数据过大)
- HDU - 4396 More lumber is required (BFS 最短路)
- Lombok(1.14.8) - @NoArgsConstructor, @RequiredArgsConstructor & @AllArgsConstructor
- 杭电1242 Rescue
- apue 第14章 高级I/O
- Android BuildConfig使用
- target/action设计模式
- iOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale)
- Xamarin.Forms 优秀UI界面
- Xcode6 有关Unknown type name ’UIImage‘问题的解决办法
- D - BestCoder Sequence
- android UI设计 layout_weight解析
- hdu 5312 Sequence(数学)
- Can you answer these queries?---hdu4027