一、
package com.wang.utils; import java.util.HashMap; import java.util.Map; import java.util.Set; public class MapUtils { public static String parseParamMapToQueryStr(Map<String, Object> paramMap) { StringBuilder result = new StringBuilder(); Set<Map.Entry<String, Object>> entries = paramMap.entrySet(); for (Map.Entry<String, Object> entry : entries) { String key = entry.getKey(); Object value = entry.getValue(); result.append("&").append("search_").append(key).append("=").append(value); } return result.toString(); } public static Map<String, Object> parseParamMapToMyBatisMap(Map<String, Object> paramMap) { Map<String, Object> resultMap = new HashMap<String, Object>(); Set<Map.Entry<String, Object>> entries = paramMap.entrySet(); for (Map.Entry<String, Object> entry : entries) { String key = entry.getKey(); Object value = entry.getValue(); if(key.startsWith("like")){ key= key.substring(key.indexOf("_")+1); value="%"+value+"%"; } resultMap.put(key,value); } return resultMap; } }