Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 弹簧靴替换字符“?”和“&”_Spring Boot_Replace - Fatal编程技术网

Spring boot 弹簧靴替换字符“?”和“&”

Spring boot 弹簧靴替换字符“?”和“&”,spring-boot,replace,Spring Boot,Replace,我有一个url字符串,我用条件添加参数。最后,我想替换是否存在字符串?&by?,但我收到一个错误 我的代码: 错误: ??是正则表达式的保留字符,您需要对其进行转义,请尝试 url = url.replaceAll("\\?&", "?"); 尝试避开问号\\& java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0 url = url.replaceAll("\\?&"

我有一个url字符串,我用条件添加参数。最后,我想替换是否存在字符串?&by?,但我收到一个错误

我的代码:

错误:

??是正则表达式的保留字符,您需要对其进行转义,请尝试

url = url.replaceAll("\\?&", "?");

尝试避开问号\\&
java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0
url = url.replaceAll("\\?&", "?");