遇到问题:数据库中含有转义的字符,查询异常
数据库:
查询结果
解决方法
一、背景
工作中遇到表字段里面记录requestBody存放了转义字符,接口开发返回去转义字符;
二、引依赖包
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
三、解决方法
@org.junit.Test
public void test02(){
String tmp = StringEscapeUtils.unescapeJava("h\\\\");
System.out.println(tmp);
}
输出结果:
com.yunjiacloud.health.Test,test02
h\
Process finished with exit code 0
原文链接:https://blog.csdn.net/qq_41732361/article/details/118363952