zoukankan      html  css  js  c++  java
  • 使用treemap 遍历map参数

    遍历格式 XXX=123&XXX=456.....参数为map

    treemap是一个有序的key-value集合,它是通过红黑树实现的

    TreeMap<String, String> treeMap = new TreeMap<>();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if ("signature".equals(entry.getKey().trim())) {
                    continue;
                }
                if (StringUtils.isBlank(entry.getValue())) {
                    continue;
                }
                treeMap.put(entry.getKey(), entry.getValue());
            }
            StringBuilder stringBuilder = new StringBuilder();
            for (Map.Entry<String, String> entry : treeMap.entrySet()) {
                stringBuilder.append(entry.getKey());
                stringBuilder.append("=");
                stringBuilder.append(entry.getValue());
                stringBuilder.append("&");
            }
            String result = "";
            if (StringUtils.isNotBlank(stringBuilder.toString())) {
                result = stringBuilder.substring(0, stringBuilder.length() - 1);
            }
            return result;
        }

  • 相关阅读:
    【应用安全】mssql db_owner权限拿shell
    【应用安全——XSS】input-hidden
    留言板
    Git配置多个SSH-Key
    13.InternalThreadLocalMap
    10.ChannelOutboundBuffer
    9.ChannelHandlerContext
    8.Future&Promise
    7.给大动脉来一刀-NioEventLoop 源码分析
    6.给大动脉来一刀
  • 原文地址:https://www.cnblogs.com/wirr/p/8397659.html
Copyright © 2011-2022 走看看