前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java Web中pageContext的20个实用方法——开发常用

Java Web中pageContext的20个实用方法——开发常用

作者头像
用户1289394
发布2018-02-27 14:57:13
6280
发布2018-02-27 14:57:13
举报
文章被收录于专栏:Java学习网Java学习网

pageContext属性默认在当前页面是共享的 pageContext表示一个javax.servlet.jsp.PageContext对象。pageContext对象提供了对JSP页面内所有的对象及名字空间的访问,也就是说他可以访问到本页所在的session,也可以取本页面所在的application的某一属性值。

网络配图 1、JspWriter getOut() 返回当前客户端响应被使用的JspWriter流(out) 2、HttpSession getSession() 返回当前页中的HttpSession对象(session) 3、Object getPage() 返回当前页的Object对象(page) 4、ServletRequest getRequest() 返回当前页的ServletRequest对象(request) 5、ServletResponse getResponse() 返回当前页的ServletResponse对象(response) 6、Exception getException() 返回当前页的Exception对象(exception) 7、ServletConfig getServletConfig() 返回当前页的ServletConfig对象(config) 8、ServletContext getServletContext() 返回当前页的ServletContext对象(application) 9、void setAttribute(String name,Object attribute) 设置属性及属性值 10、void setAttribute(String name,Object obj,int scope) 在指定范围内设置属性及属性值 11、public Object getAttribute(String name) 取属性的值

网络配图 12、Object getAttribute(String name,int scope) 在指定范围内取属性的值 13、public Object findAttribute(String name) 寻找一属性,返回起属性值或NULL 14、void removeAttribute(String name) 删除某属性 15、void removeAttribute(String name,int scope) 在指定范围删除某属性 16、int getAttributeScope(String name) 返回某属性的作用范围 17、Enumeration getAttributeNamesInScope(int scope) 返回指定范围内可用的属性名枚举 18、void release() 释放pageContext所占用的资源 19、void forward(String relativeUrlPath) 使当前页面重导到另一页面 20、void include(String relativeUrlPath) 在当前位置包含另一文件

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-11-09,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Java学习网 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档