本文整理汇总了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.");
}
示例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);
}
}
示例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;
}
示例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;
}