admin 管理员组

文章数量: 1087139


2024年1月13日发(作者:软考2022年下半年报名时间)

public String formPost(String url, Map params) throws IOException { if (url == null || ().length() <= 0) { throw new IllegalArgumentException("POST url can not be empty"); } Map response = new HashMap(); PostMethod poster = new PostMethod(url); String content = ""; String encoding = _8; String contentType = "application/x-www-form-urlencoded;charset=" + encoding; if (params != null && () > 0) { content = format(params, encoding); } StringRequestEntity entity = new StringRequestEntity(content, contentType, encoding); uestEntity(entity); eMethod(poster); return responseBodyAsString(poster); } private static String format(Map parameters, final String encoding) { final StringBuilder sb = new StringBuilder(); Set<> entrySet = et(); Iterator<> iterator = or(); while (t()) { entry = (); final String encodedName = encode((), encoding); final String value = ue(); final String encodedValue = value != null ? encode(value, encoding) : ""; if (() > 0) { ("&"); } (encodedName); ("="); (encodedValue); } return ng(); } public static String decode(final String content, final String encoding) { try { return (content, encoding != null ? encoding : T_CONTENT_CHARSET); } catch (UnsupportedEncodingException problem) { throw new IllegalArgumentException(problem); } } public static String encode(final String content, final String encoding) { try { return (content, encoding != null ? encoding : T_CONTENT_CHARSET); } catch (UnsupportedEncodingException problem) { throw new IllegalArgumentException(problem); } }


本文标签: 时间 报名