方法一:java
經過程序遍歷http請求的全部參數放到hashmap中,用的時候方便了。blog
若是參數值有中文,那麼須要在程序中添加filter轉碼,或者在下面程序裏,對paramValue轉碼get
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) { System.out.println("參數:" + paramName + "=" + paramValue); map.put(paramName, paramValue); } } } }
方法二:hash
Map paramMap = new HashMap(); paramMap = request.getParameterMap();