Common creation of post request parameter to map collection

Convert long request parameters into a map collection for easy access to parameters

public Map<String, Object> getValue(HttpServletRequest request) {
		Map<String, Object> map = new HashMap<String, Object>();

		try {
			String key = "";
			String value = "";
			Iterator<String> it = request.getParameterMap().keySet().iterator();
			while (it.hasNext()) {
				key = it.next();
				value = ((Object[]) (request.getParameterMap().get(key)))[0]
						.toString();
				//value = value.getBytes(value,"UTF-8");
				
				map.put(key, value);
			}

		} catch (Exception e) {
			return null;
		}

		return map;
	}

Guess you like

Origin blog.csdn.net/qq_42258975/article/details/108577631