一:直接定义函数进行处理

public static String escapeStr(String str) {
if (StringUtils.isEmpty(str)) {
str = str.replaceAll("\\\\", "\\\\\\\\");
str = str.replaceAll("_", "\\\\_");
str = str.replaceAll("%", "\\\\%");
}
return str;
}

 二:Mapper 中sql 处理

select * from staff where name like CONCAT('%', '%' , '%') escape '%';

 

相关文章:

  • 2021-08-07
  • 2022-12-23
  • 2021-10-16
  • 2021-08-07
  • 2021-05-26
  • 2022-12-23
猜你喜欢
  • 2021-11-12
  • 2022-12-23
  • 2021-12-17
  • 2021-05-16
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案