JspContext源码翻译

来源:互联网 发布:91熊猫看书软件 编辑:程序博客网 时间:2024/05/17 22:15
package javax.servlet.jsp;import java.util.Enumeration;import javax.el.ELContext;/** * <p>JspContext是PageContext抽象类的基类,并抽象所有不针对servlet的信息。 * 这允许在请求/响应上下文之外使用简单的标记扩展。 *  * <p>JspContext为页面/组件创建者和页面实现者提供以下工具: *     a. 管理各种范围的名称空间的API; *     b. 获取JspWriter的机制; *     c. 向脚本环境公开页面指令属性的机制。 * <p>用于容器生成代码的方法: *    能够管理内嵌的JspWriter流去实现标签扩展:pushBody()和popBody() * <p>用于JSP创建的方法: *    一些方法提供统一访问不同表示范围的对象。实现必须使用对应于该范围的底层机制。因此, * 信息可以在底层环境(例如servlet)和JSP页面之间来回传递。方法是: *     setAttribute(),getAttribute(),findAttribute(), *     removeAttribute(),getAttributesScope(), *     getAttributeNamesInScope()。 * <p>获取隐式对象的方法:getOut() * <p>EL计算器的方法:getExpressionEvaluator(),getVariableResolver()。 * @author TCM * @create 2017年10月27日下午1:32:10 * @since  JSP 2.0 */public abstract class JspContext {        public JspContext() {    }        //注册页面范围的属性    abstract public void setAttribute(String name, Object value);    //scope是属性范围,参考:PageContext    abstract public void setAttribute(String name, Object value, int scope);    abstract public Object getAttribute(String name);    abstract public Object getAttribute(String name, int scope);    abstract public Object findAttribute(String name);    abstract public void removeAttribute(String name);    abstract public void removeAttribute(String name, int scope);    //获取属性的范围    abstract public int getAttributesScope(String name);    //获取指定范围内的所有属性名    abstract public Enumeration<String> getAttributeNamesInScope(int scope);        //JspWriter对象:响应客户端中使用    abstract public JspWriter getOut();            /**     * 返回与JspContext相关的ELContext。     *      * <p>ELContext被惰性地创建,同时若果已经存在,则重用。     * 每一个JspContext都有一个新的ELContext。     *      * <p>在JSP规格中,ELContext必须含有ELResolver。     * {@link JspApplicationContext#addELResolver}     * @return {@link ELContext}     * @since JSP 2.1     */    public abstract ELContext getELContext();    /**     * 返回JspWriter对象     * 作用:保存当前的out对象,并更新PageContext中Page范围内Out对象     * 参考资料:http://xiaodiandian.iteye.com/blog/662995     * @since JSP 2.0     */    public JspWriter pushBody( java.io.Writer writer ) {        return null; // XXX to implement    }        public JspWriter popBody() {        return null; // XXX to implement    }}

原创粉丝点击