通过URL传递JSON格式参数的问题
我写了一个一个URL如下:
http://localhost:8080/servlet/user?param={"accID":"milo","field":"nick_name,email"}
使用httpclient进行调用的时候却发现URL语法错误。
那该如何传递JSON格式的数据呢?
------解决方案--------------------
http://localhost:8080/servlet/user?param={%22accID%22:%22milo%22,%22field%22:%22nick_name,email%22}
转义
------解决方案--------------------
HttpHost target= new HttpHost ("http://localhost:8080");
HttpGet get = new HttpGet("/servlet/user?param=%7B%22accID%22%3A%22milo%22%2C%22field%22%3A%22nick_name%2Cemail%22%7D");
至少解析是没问题的。呵呵。