2023年6月25日发(作者:)
http请求参数中含有或者空格,则必须URL编码http请求参数中含有& 或者空格,则必须URL编码发送请求时,会先把请求参数转化为形如:a=a1&b=b1&c=c1
updateParameter会调⽤RequestPanel中的getRequestBodyFromList, 参考com/common/bean/中的getQueryString⽅法 ldURLEncode就是⽤来智能地判断是否需要URL转码,⽬前的规则是:http请求参数中含有&
或者空格,则必须URL编码具体代码:/*** * 是否包含指定字符串,不区分⼤⼩写 *
* @param input * : 原字符串 * @param regex * @return */ public static boolean contain2(String input, String regex) { /*** * input:(1)bss登录(2)
regex:bss登录(2) */ regex = e("(", "("); regex = e(")", ")"); if (OrEmpty(input)) { return false; } Pattern p = e(regex, _INSENSITIVE); Matcher m = r(input); boolean result = (); return result; } /*** * 是否需要URL编码
* http请求参数中含有& 或者空格,则必须URL编码 * * @param value * @return */ public static boolean isShouldURLEncode(String value) { return !OrEmpty(value) && (ns("&") || n2(value, "[s]")); }
优化:GET请求时,参数含有中⽂,也需要URL编码: public static boolean isHasChinses(String str) { String encodeName = "UTF-8"; for (int i = 0; i < (); i++) { try { String singleStr = ing(i, i + 1); int leng = getEncodeLength(singleStr, encodeName); // n(singleStr + "t" + leng); if (leng == 9)// 表⽰是中⽂字符 { // n("有中⽂"); return true; } } catch (UnsupportedEncodingException e) { tackTrace(); } catch (MyException e) { tackTrace(); } catch (Exception e) { tackTrace(); } } return false; } /*** * 是否需要URL编码
* http请求参数中含有& 或者空格,则必须URL编码 * * @param value * @return */ public static boolean isShouldURLEncode(String value) { return !OrEmpty(value) && (ns("&") || n2(value, "[s]") || hinses(value)); }
发布者:admin,转转请注明出处:http://www.yc00.com/web/1687679739a30968.html
评论列表(0条)