zoukankan      html  css  js  c++  java
  • Http请求中的request参数重新组装成Map的工具类实现

    • 将请求的request的参数重新组装。主要是将空值的替换成null,因为requestMap空值是" ",这样处理有利于外部判断, 同时将获取到的值映射到页面上
    protected Map<String, Object> assemblyRequestMap(HttpServletRequest request) {
        Map<String, Object> params = new HashMap<String, Object>();
        Map<String, String[]> map = request.getParameterMap();
        Iterator<String> key = map.keySet().iterator();
        while (key.hasNext()) {
            String k = (String) key.next();
            String[] value = map.get(k);
            if (value.length == 1) {
                String temp = null;
                if (!StringUtil.isBlank(value[0])) {
                    temp = value[0];
                }
                params.put(k, temp);
                request.setAttribute(k, temp);
            } else if (value.length == 0) {
                params.put(k, null);
                request.setAttribute(k, null);
            } else if (value.length > 1) {
                params.put(k, value);
                request.setAttribute(k, value);
            }
        }
        return params;
    }
  • 相关阅读:
    javascript 数字格式化
    spring-cloud blogs
    rabbitmq python
    centos7下 安装mysql
    hue install
    d3 document
    elastichq 离线安装
    elasticsearch agg
    elastichq auto connect
    Go Hello World!
  • 原文地址:https://www.cnblogs.com/superSubfn/p/12190737.html
Copyright © 2011-2022 走看看