【代码优化】增强 JDK17、JDK8 之间的兼容性

This commit is contained in:
YunaiV 2025-08-29 13:33:21 +08:00
parent 187acad8bf
commit a1b07adbf6

View File

@ -190,7 +190,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
@SneakyThrows
private static String percentCode(String str) {
Assert.notNull(str, "str 不能为空");
return URLEncoder.encode(str, StandardCharsets.UTF_8)
return HttpUtils.encodeUtf8(str)
.replace("+", "%20") // 加号 "+" 被替换为 "%20"
.replace("*", "%2A") // 星号 "*" 被替换为 "%2A"
.replace("%7E", "~"); // 波浪号 "%7E" 被替换为 "~"