goja-web/src/main/java/goja/mvc/kits/Servlets.java
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>();
        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;
    }
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>();
        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;
    }
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 > ( ) ; 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 ; }
取得带相同前缀的Request Parameters, copy from spring WebUtils. <p/> 返回的结果的Parameter名已去除前缀.
取得带相同前缀的Request Parameters copy from spring WebUtils . <p / > 返回的结果的Parameter名已去除前缀 .