lemonrace
lemonrace
采纳率0%
2016-07-25 08:23 阅读 1.8k

httpclient发送json后台接收到不是json格式

发送的json:{"abel":"6","act":"get","attrib":"5","did":"1","pid":"2","srv":"4","tpid":"3"}
数据发送的代码:
StringEntity entity = new StringEntity(json);
entity.setContentType("application/json");
entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"));
// entity.setContentEncoding("UTF-8");
httppost.setEntity(entity);

接收到的数据格式:调用函数request.getParameterMap()
{{"abel":"6","act":"get","attrib":"5","did":"1","pid":"2","srv":"4","tpid":"3"}=[Ljava.lang.String;@5abf00}

期望得到的数据格式:
{"did":["1"],"pid":["2"],"tpid":["3"],"srv":["4"],"act":["get"],"attrib":["5"],"abel":["6"]}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • ChococlateTan ChocolateTan 2016-07-25 08:24

    发送的json1、2、3、4、5、6的key改成数组类型

    点赞 评论 复制链接分享
  • bdmh bdmh 2016-07-25 08:34

    让后台给你修改,格式是后台生成的

    点赞 评论 复制链接分享

相关推荐