後端接收數據解析HttpServletRequest

 public JSONObject updateProductState(HttpServletRequest request) {

        Map<String, Object> map = Utils.convertToMap(request);
        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 && !paramName.equals("table")) {
                    map.put(paramName, paramValue);
                }
            }
        }
        Logger.info("提交product和scheme" + map);
        String productId = map.get("productId").toString();
        String schemeIds = map.get("schemeIds") == null ? null :         
        map.get("schemeIds").toString();

    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章