1.先封装HashMap

Map<String,Object> map=new HashMap<String,Object>();
map.put("name","老王");
map.put("id","195");

2.将map转换为JSONObject类型

JSONObject jsonObject=JSONObject.fromObject(map);

3.将jsonObject转换为字符串并打印

String str =jsonObject.toString();
System.out.println(str);

 4.将转换后的字符串str作为key存入Redis

@Cacheable(value{"userServ"},key="'userJpushObject'.concat(#str)")
@Override
public UserJpush selectByPrimaryKey(String str) {
    return getMapper().select(str);
}            

 

相关文章:

  • 2022-12-23
  • 2021-03-31
  • 2021-12-06
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-03-05
猜你喜欢
  • 2021-07-25
  • 2021-09-18
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
相关资源
相似解决方案