在进行https通讯时,服务器接收方收到的中文编码是类似%E4%B8%AD%E5%9B%BD种格式的,那么怎么把他还原呢?
服务器端:String encodeStr = URLEncoder.encode("中国", "utf-8"); System.out.println("处理后:" + encodeStr); //处理后:%E4%B8%AD%E5%9B%BD 客户端:String decodeStr = URLDecoder.decode(encodeStr, "utf-8"); System.out.println("解码:" + decodeStr);

本文介绍了一种在HTTPS通信中处理中文编码的方法。当服务器接收到类似%E4%B8%AD%E5%9B%BD这样的编码时,可以使用URLDecoder.decode()方法配合UTF-8编码将其转换回正常的中文字符。
1808

被折叠的 条评论
为什么被折叠?



