/** * @return all attributes */ public Set<String> attributes() { Set<String> attrList = new HashSet<>(); Enumeration<String> attributes = (Enumeration<String>) servletRequest.getAttributeNames(); while (attributes.hasMoreElements()) { attrList.add(attributes.nextElement()); } return attrList; }
public boolean isEmpty() { return !request.getAttributeNames().hasMoreElements(); }
Enumeration<?> attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); if (this.cleanupAfterInclude || attrName.startsWith(DEFAULT_STRATEGIES_PREFIX)) { attrsToCheck.add(attrName); request.removeAttribute(attrName); else if (attrValue != request.getAttribute(attrName)) { request.setAttribute(attrName, attrValue);
public void visitAttributes() { Map<String, Object> keyValues = createTreeMap(); for (String name : enumToList(request.getAttributeNames())) { keyValues.put(name, request.getAttribute(name)); } keyValuesComponent.visitTemplate(context, keyValues); }
@Override public Map<String, Object> getAttributes() { // build map of attributes Map<String,Object> attributes = new HashMap<>(); Enumeration<String> en = httpServletRequest.getAttributeNames(); while (en.hasMoreElements()) { String name = en.nextElement(); Object value = httpServletRequest.getAttribute(name); attributes.put(name, value); } return attributes; }
public int size() { int result = 0; for (Enumeration enumeration = request.getAttributeNames(); enumeration.hasMoreElements(); ) { enumeration.nextElement(); ++result; } return result; }
@Override public Map<String, Object> attributes() { final Enumeration<String> attributeNames = req.getAttributeNames(); if (!attributeNames.hasMoreElements()) { return Collections.emptyMap(); } return Collections.list(attributeNames).stream() .collect(Collectors.toMap(Function.identity(), req::getAttribute)); }
public void visitAttributes() { Map<String, Object> keyValues = createTreeMap(); for (String name : enumToList(request.getAttributeNames())) { keyValues.put(name, request.getAttribute(name)); } keyValuesComponent.visitTemplate(context, keyValues); }
/** * 将Request中的数据转换为模板引擎<br> * 取值包括Session和Request * @param context 内容 * @param request 请求对象 * @return VelocityContext */ public static VelocityContext parseRequest(VelocityContext context, javax.servlet.http.HttpServletRequest request) { final Enumeration<String> attrs = request.getAttributeNames(); if (attrs != null) { String attrName = null; while (attrs.hasMoreElements()) { attrName = attrs.nextElement(); context.put(attrName, request.getAttribute(attrName)); } } return context; }
public Set<String> getVariableNames() { // -------------------------- // Note this method relies on HttpServletRequest#getAttributeNames(), which is an extremely slow and // inefficient method in implementations like Apache Tomcat's. So the uses of this method should be // very controlled and reduced to the minimum. Specifically, any call that executes e.g. for every // expression evaluation should be disallowed. Only sporadic uses should be done. // Note also it would not be a good idea to cache the attribute names coming from the request if we // want to keep complete independence of the HttpServletRequest object, so that it can be modified // from the outside (e.g. from other libraries like Tiles) with Thymeleaf perfectly integrating with // those modifications. // -------------------------- final Set<String> variableNames = new HashSet<String>(10); final Enumeration<String> attributeNamesEnum = this.request.getAttributeNames(); while (attributeNamesEnum.hasMoreElements()) { variableNames.add(attributeNamesEnum.nextElement()); } return variableNames; }
public Map<String, Object> getServletAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); for (String name : Collections.list(req.getAttributeNames())) { attributes.put(name,req.getAttribute(name)); } return attributes; }
/** * 将Request中的数据转换为模板引擎<br> * 取值包括Session和Request * @param context 内容 * @param request 请求对象 * @return VelocityContext */ public static VelocityContext parseRequest(VelocityContext context, javax.servlet.http.HttpServletRequest request) { final Enumeration<String> attrs = request.getAttributeNames(); if (attrs != null) { String attrName = null; while (attrs.hasMoreElements()) { attrName = attrs.nextElement(); context.put(attrName, request.getAttribute(attrName)); } } return context; }
public TemplateCollectionModel keys() { ArrayList keys = new ArrayList(); for (Enumeration enumeration = request.getAttributeNames(); enumeration.hasMoreElements(); ) { keys.add(enumeration.nextElement()); } return new SimpleCollection(keys.iterator()); }
public Map<String, Object> getServletAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); for (String name : Collections.list(req.getAttributeNames())) { attributes.put(name,req.getAttribute(name)); } return attributes; }
private void supportActiveRecord(HttpServletRequest request) { for (Enumeration<String> attrs = request.getAttributeNames(); attrs.hasMoreElements();) { String key = attrs.nextElement(); Object value = request.getAttribute(key); request.setAttribute(key, handleObject(value, DEPTH)); } }
@Override public Enumeration<String> getHeaderNames() { Set list = new HashSet(); list.addAll(b.headers.keySet()); list.addAll(Collections.list(b.request.getHeaderNames())); if (b.request != null) { Enumeration e = b.request.getAttributeNames(); while (e.hasMoreElements()) { String name = e.nextElement().toString(); if (name.startsWith(X_ATMOSPHERE)) { list.add(name); } } } if (b.contentType != null) { list.add("Content-Type"); } return Collections.enumeration(list); }
public static void dumpRequestAttributes(final StringBuffer sb, final HttpServletRequest request, final String lf, final String indent) { for (final Iterator it = toSortedSet(request.getAttributeNames()) .iterator(); it.hasNext();) { final String name = (String) it.next(); final Object attr = request.getAttribute(name); sb.append(indent); sb.append("[request]").append(name).append("=").append(attr); sb.append(lf); } }
public TemplateCollectionModel values() { ArrayList values = new ArrayList(); for (Enumeration enumeration = request.getAttributeNames(); enumeration.hasMoreElements(); ) { values.add(request.getAttribute((String) enumeration.nextElement())); } return new SimpleCollection(values.iterator(), wrapper); }
private static void load(HttpServletRequest request, Builder b) { Enumeration<String> e = request.getHeaderNames(); String s; while (e.hasMoreElements()) { s = e.nextElement(); b.headers.put(s, request.getHeader(s)); } synchronized (b.request) { e = request.getAttributeNames(); } while (e.hasMoreElements()) { s = e.nextElement(); b.localAttributes.put(s, attributeWithoutException(request, s)); } e = request.getParameterNames(); while (e.hasMoreElements()) { s = e.nextElement(); b.queryStrings.put(s, request.getParameterValues(s)); } b.queryString = request.getQueryString(); Enumeration<Locale> l = request.getLocales(); while (l.hasMoreElements()) { b.locale(l.nextElement()); } }
@SuppressWarnings("unchecked") @Override public Map<String, Object> getAllData() { Map<String, Object> results = new LinkedHashMap<>(); Iterable<String> iterable = iterable(req.getAttributeNames()); for (String name : iterable) { results.put(name, req.getAttribute(name)); } return results; }