1. 程式人生 > >獲取 HttpServletRequest 所有引數封裝在map集合中

獲取 HttpServletRequest 所有引數封裝在map集合中

獲取 HttpServletRequest 所有引數封裝在map集合中 

 /**
     * 解析第三方返回值
     *
     * @param request
     *            請求
     * @return map
     */
    private Map analyseCallbackRequest(HttpServletRequest request)
    {
        
        Map map = new HashMap();
        Enumeration paramNames = request.getParameterNames();
        while (paramNames.hasMoreElements())
        {
            String paramName = (String) paramNames.nextElement();
            String[] paramValues = request.getParameterValues(paramName);
            if (paramValues.length == 1)
            {
                String paramValue = paramValues[0];
                if (paramValue.length() != 0)
                {
                    map.put(paramName, paramValue);
                }

            }
        }
        return map;
    }