首先你需要保证要转换的Object的实际类型是Map假设Object变量名为obj,强制转换(Map)obj转换前最好进行类型检查,防止出现ClassCastException
Object obj = new Object();@SuppressWarnings("unused") Map map = (Map)obj;
Object o1 = new Object();Map map = (Map)o1;
public Map hgetall(String key) { Map entries = mStringRedisTemplate.opsForHash().entries(key); return new HashMap(entries);}
你应该是想把object 放入MAP中吧然后在拿出来是吗?