当前位置: 首页>>代码示例>>Java>>正文


Java JspContext.getAttribute方法代码示例

本文整理汇总了Java中javax.servlet.jsp.JspContext.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java JspContext.getAttribute方法的具体用法?Java JspContext.getAttribute怎么用?Java JspContext.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.jsp.JspContext的用法示例。


在下文中一共展示了JspContext.getAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanFactory

import javax.servlet.jsp.JspContext; //导入方法依赖的package包/类
/**
 * Gets the {@link BeanFactory} from the given {@link JspContext}. The default
 * implementation automagically finds a {@link BeanFactory} that was previously set by
 * a {@link FrameworkServlet}. The result is cached.
 *
 * @param jspContext
 *            {@link JspContext} to be used
 * @return {@link BeanFactory} found
 */
@SuppressWarnings("unchecked")
protected BeanFactory getBeanFactory(JspContext jspContext) {
    Object bfCache = jspContext.getAttribute(TAGPROXY_BEANFACTORY_CACHE, PageContext.APPLICATION_SCOPE);
    if (bfCache != null && bfCache instanceof BeanFactory) {
        return (BeanFactory) bfCache;
    }

    Enumeration<String> en = jspContext.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
    while (en.hasMoreElements()) {
        String attribute = en.nextElement();
        if (attribute.startsWith(FrameworkServlet.SERVLET_CONTEXT_PREFIX)) {
            Object bf = jspContext.getAttribute(attribute, PageContext.APPLICATION_SCOPE);
            if (bf != null && bf instanceof BeanFactory) {
                BeanFactory bfBean = (BeanFactory) bf;
                jspContext.setAttribute(TAGPROXY_BEANFACTORY_CACHE, bfBean, PageContext.APPLICATION_SCOPE);
                return bfBean;
            }
        }
    }

    throw new IllegalStateException("Could not find a BeanFactory. Use a FrameworkServlet or @BeanFactoryReference.");
}
 
开发者ID:shred,项目名称:commons-taglib,代码行数:32,代码来源:AbstractTagProxy.java

示例2: getValue

import javax.servlet.jsp.JspContext; //导入方法依赖的package包/类
@Override
public Object getValue(ELContext context, Object base, Object property) {
    JspContext pageContext = (JspContext) context.getContext(JspContext.class);
    Boolean escapeXml = (Boolean) pageContext.getAttribute(ESCAPE_XML_ATTRIBUTE);
    if (escapeXml != null && !escapeXml) {
        return null;
    }

    try {
        if (excludeMe.get()) {
            return null;
        }

        // This resolver is in the original resolver chain. To prevent
        // infinite recursion, set a flag to prevent this resolver from
        // invoking the original resolver chain again when its turn in the
        // chain comes around.
        excludeMe.set(Boolean.TRUE);
        Object value = context.getELResolver().getValue(
                context, base, property);

        if (value instanceof String) {
            value = EscapeXml.escape((String) value);
        }
        return value;

    } finally {
        excludeMe.set(Boolean.FALSE);
    }
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:31,代码来源:EscapeXmlELResolver.java

示例3: getUid

import javax.servlet.jsp.JspContext; //导入方法依赖的package包/类
public static String getUid(JspContext context) {
	String uuid = null;
	do {
		long rand = Double.doubleToLongBits(Math.random());
		uuid = Long.toHexString(rand).substring(0, 4);
	} while (context.getAttribute(uuid) != null);
	context.setAttribute(uuid, uuid);
	return uuid;
}
 
开发者ID:Mrdigs,项目名称:Bootstrap.jsp,代码行数:10,代码来源:UidGenerator.java

示例4: getUserInfo

import javax.servlet.jsp.JspContext; //导入方法依赖的package包/类
public static Map<String, Object> getUserInfo(JspContext jspContext) {
	@SuppressWarnings("unchecked")
	Map<String, Object> userInfo = (Map<String, Object>) jspContext
			.getAttribute(WizardWedConstant.SESSION_USER_INFO,
					PageContext.SESSION_SCOPE);
	return userInfo;
}
 
开发者ID:joaquinaimar,项目名称:wizard,代码行数:8,代码来源:WizardWebUtils.java


注:本文中的javax.servlet.jsp.JspContext.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。