【问题标题】:When I'm using URLEncoder for Http GET Request I'm getting proper URL but when I push that code to live or on server I'm getting error当我将 URLEncoder 用于 Http GET 请求时,我得到了正确的 URL,但是当我将该代码推送到实时或服务器上时,我得到了错误
【发布时间】:2018-01-20 02:53:10
【问题描述】:

当我将 URLEncoder 用于 Http GET 请求时,我得到了正确的 URL,但是当我将该代码推送到实时或服务器上时,我得到了错误。

原因是在live或者server超过3个空格被转换成%09即。 5个空格变成+++%09

hmMailDetails.put("content", URLEncoder.encode(sContent.trim(),"UTF-8"));     

【问题讨论】:

  • 听起来更像是实际问题可能是您无法正确区分空格和制表符(因为%09 是后者)...

标签: java apache http url urlencode


【解决方案1】:

只是我已将 %09 替换为 %20........ String cont = URLEncoder.encode(sContent.trim(),"UTF-8"); hmMailDetails.put("content",cont.replace("+", "%20").replace("%09", "%20"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-23
    • 2015-02-04
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    • 2020-12-28
    相关资源
    最近更新 更多