List of usage examples for javax.servlet ServletRequest getParameterNames
public Enumeration<String> getParameterNames();
Enumeration
of String
objects containing the names of the parameters contained in this request. From source file:com.shz.foundation.utils.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * /*from www . jav a2 s.c om*/ * Parameter???. */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { Validate.notNull(request, "Request must not be null"); Enumeration<String> paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while ((paramNames != null) && paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; }
From source file:com.emaxcore.emaxdata.common.web.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * * Parameter???./*from ww w . j a v a 2 s . com*/ */ @SuppressWarnings("rawtypes") public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap(); String pre = prefix; if (pre == null) { pre = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(pre) || paramName.startsWith(pre)) { String unprefixed = paramName.substring(pre.length()); String[] values = request.getParameterValues(paramName); if (values != null && values.length > 1) { params.put(unprefixed, values); } else { if (values != null && values.length == 1) { params.put(unprefixed, values[0]); } } } } return params; }
From source file:com.innovate.cms.common.web.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * /*from ww w.j a va 2s. co m*/ * Parameter???. */ @SuppressWarnings("rawtypes") public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); String pre = prefix; if (pre == null) { pre = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(pre) || paramName.startsWith(pre)) { String unprefixed = paramName.substring(pre.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { values = new String[] {}; // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; }
From source file:com.github.tx.archetype.common.util.Servlets.java
/** * ???Request ParametersParameter???/* w w w .jav a2 s .com*/ * @param request * @param prefix ? * @param ignoreEmptyValue ? * @return */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix, boolean ignoreEmptyValue) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = Maps.newHashMap(); if (prefix == null) { prefix = ""; } while ((paramNames != null) && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values != null && values.length > 0) { for (int i = 0; i < values.length; i++) { values[i] = values[i].trim(); } } if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { if (!ignoreEmptyValue) { params.put(unprefixed, values[0]); } else { if (StringUtils.isNotBlank(values[0])) { params.put(unprefixed, values[0]); } } } } } return params; }
From source file:com.cnksi.core.web.utils.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * /*from w w w . j a va 2 s.c om*/ * Parameter???. * * @param dwzExport true|false ?ExcelValue??? */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix, boolean dwzExport) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } if (dwzExport) { Iterator<String> it = params.keySet().iterator(); while (it.hasNext()) { try { String key = it.next(); String value = params.get(key).toString(); String encodedValue = new String(value.getBytes("ISO8859-1"), "UTF-8"); params.put(key, encodedValue); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } return params; }
From source file:com.age.core.utils.web.ServletUtils.java
/** * ???Request Parameters.//from ww w . j a v a 2 s. c o m * * Parameter???. */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { AssertUtils.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; }
From source file:com.soolr.core.web.Servlets.java
/** * ?Request Parameters, copy from spring WebUtils. * // w ww . j av a 2s . c om * Parameter */ @SuppressWarnings("rawtypes") public static Map<String, Object> getParameters(ServletRequest request) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); while ((paramNames != null) && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); String[] values = request.getParameterValues(paramName); if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(paramName, values); } else { params.put(paramName, values[0]); } } return params; }
From source file:com.soolr.core.web.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * //www.j ava 2s .c o m * Parameter???. */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); String prefix_ = prefix == null ? "" : prefix; while ((paramNames != null) && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix_) || paramName.startsWith(prefix_)) { String unprefixed = paramName.substring(prefix_.length()); String[] values = request.getParameterValues(paramName); if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; }
From source file:com.soolr.core.web.Servlets.java
/** * ???Request Parameters, copy from spring WebUtils. * //from w ww . j av a 2 s. co m * Parameter???. */ public static Map<String, Object> getPmParametersStartingWith(ServletRequest request, String prefix) { Validate.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); String prefix_ = prefix == null ? "" : prefix; while ((paramNames != null) && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix_) || paramName.startsWith(prefix_)) { String unprefixed = paramName.substring(prefix_.length()); String[] values = request.getParameterValues(paramName); if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } else {//?? String[] values = request.getParameterValues(paramName); if ((values == null) || (values.length == 0)) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(paramName, values); } else { params.put(paramName, values[0]); } } } return params; }
From source file:com.sunway.cbm.util.ServletUtils.java
/** * ???Request Parameters./* ww w . j a v a 2s . c o m*/ * * Parameter???. */ public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { AssertUtils.notNull(request, "Request must not be null"); Enumeration<?> paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; }