URL解析错误

xiaoxiao2021-02-28  46

URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "","

问题描述:今天使用post发送json串时发生如上url解析错误,因为pojo中包含了%号。解决方法如下所示。 

pojo = pojo.replaceAll("%(?![0-9a-fA-F]{2})", "%"); /** * POJO 转 JSON */ public static <T> String getJson(T tResponse) throws Exception{ String pojo = JSONObject.toJSONString(tResponse); pojo = pojo.replaceAll("%(?![0-9a-fA-F]{2})", "%"); return URLDecoder.decode(pojo, "utf-8"); }
转载请注明原文地址: https://www.6miu.com/read-2624654.html

最新回复(0)