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;
        }

  • 相关阅读:
    2019-8-31-dotnet-新项目格式与对应框架预定义的宏
    2018-10-31-C#-程序内的类数量对程序启动的影响
    位域
    free命令
    lsof命令
    Linux挂载Windows文件夹
    Source Insight用法
    预处理命令
    QMessageBox
    QComboBox
  • 原文地址:https://www.cnblogs.com/wirr/p/8397659.html
Copyright © 2011-2022 走看看