因为业务需要,Map的key值需要在存取的时候忽略大小写。
可以通过这个阿帕奇的Commons工具类中的CaseInsensitiveMap()来解决大小写问题。
两种方式:
- 写好map进行转换:
Map<String,String> map1=new HashMap<>();
map1.put("XXs","2xs");
Map<String, String> result = new CaseInsensitiveMap(map1);
2.直接new:
Map<String,String> map1=new CaseInsensitiveMap<>();