Skip to content

Commit 2ec3c52

Browse files
committed
替换hard code
1 parent cb78119 commit 2ec3c52

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import me.chanjar.weixin.mp.bean.result.*;
2828
import me.chanjar.weixin.mp.util.http.*;
2929
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
30+
31+
import org.apache.commons.io.Charsets;
3032
import org.apache.http.Consts;
3133
import org.apache.http.HttpHost;
3234
import org.apache.http.client.ClientProtocolException;
@@ -48,6 +50,7 @@
4850
import java.io.StringReader;
4951
import java.io.UnsupportedEncodingException;
5052
import java.net.URLEncoder;
53+
import java.nio.charset.Charset;
5154
import java.security.NoSuchAlgorithmException;
5255
import java.util.*;
5356
import java.util.Map.Entry;
@@ -478,7 +481,7 @@ public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException {
478481
public String qrCodePictureUrl(String ticket) throws WxErrorException {
479482
String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s";
480483
try {
481-
return String.format(url, URLEncoder.encode(ticket, "utf-8"));
484+
return String.format(url, URLEncoder.encode(ticket, Charsets.UTF_8.name()));
482485
} catch (UnsupportedEncodingException e) {
483486
WxError error = new WxError();
484487
error.setErrorCode(-1);

0 commit comments

Comments
 (0)