我用httpclient包,模拟发送post请求,已经可以了,但是遇到一种比较特殊的post请求,求解 抓取http协议分析了之后,发现这个特殊post没有像一般的post那个的参数对,而是这样的,请各位看图片, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我这样写,不行啊。。nvps.add(new BasicNameValuePair("(Content)", (。。})); 所提交内容是JSON串,但可能没有命名。别直接看POST Data页面,去看看Stream页面的左侧,这里的信息更为原始真实,辛苦楼主贴出来看看。 POST /jwxt/xscjcxAction/xscjcxAction.action?method=getKccjList HTTP/1.1Accept: */*Accept-Language: zh-cnajaxrequest: true__clienttype: unieapresourceid: nullContent-Type: multipart/form-dataworkitemid: nullReferer: http:///jwxt/forward.action?path=//xscj/xscjcx/xsgrcj_listrender: unieapAccept-Encoding: gzip, deflateUser-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)Host: Content-Length: 827Connection: Keep-AliveCache-Control: no-cacheCookie: JSESSIONID=A7FEDF34AA0592503FDEBB10B1801CD1{header:{"code": -100, "message": {"title": "", "detail": ""}},body:{dataStores:{kccjStore:{rowSet:{"primary":[],"filter":[],"delete":[]},name:"kccjStore",pageNumber:1,pageSize:10,recordCount:11,rowSetName:"pojo_com.neusoft.education.sysu.xscj.xscjcx.model.KccjModel",order:"t.xn, t.xq, t.kch, t.bzw"}},parameters:{"kccjStore-params": [{"name": "Filter_t.pylbm_0.5561039376138874", "type": "String", "value": "'01'", "condition": " = ", "property": "t.pylbm"}, {"name": "Filter_t.xn_0.10712511051512274", "type": "String", "value": "'2010-2011'", "condition": " = ", "property": "t.xn"}, {"name": "Filter_t.xq_0.40865586464372716", "type": "String", "value": "'1'", "condition": " = ", "property": "t.xq"}, {"name": "xh", "type": "String", "value": "''", "condition": " = ", "property": "t.xh"}], "args": ["student"]}}} 没什么特殊啊,人家传的是json写的时候直接写流,而不是写键值对 哦,这种情况,直接把整个JSON作为发送内容提交出去就行了,不要加什么BasicNameValuePair。 免得你到处找了:httppost.setEntity(new StringEntity("你构造的JSON字符串")); 3Q,我刚想问你httpost.setEntity();这个东西着呢吗搞,呵呵,多谢了。 HttpPost httpost = new HttpPost(url); String a = "字符串"; try { httpost.setEntity(new StringEntity(a)); response = httpclient.execute(httpost); }是不是大题是这样? 是的,如果再出问题,就继续检查其它的参数头信息,比如:ajaxrequest: true__clienttype: unieapresourceid: nullContent-Type: multipart/form-dataworkitemid: null因为不知道对方会检查啥,所以看到长相奇特的都要引起注意。 从键盘任意输入1-9的数字以逗号分割,然后达到以上结果,我该怎么处理,在线等======== 求大虾帮忙决定一下MyEclipse的小问题 问一个概念问题 java生成文本文件的时候设置生成指定编码格式 java中的转换 String的getBytes()问题请教,谢谢! 奇怪问题:label可以竖着显示一句话吗,类似春联的? 图片显示的相对路径问题! 关于war文件和ear文件的区别,我的理解和疑惑: 关于JTable渲染器Renderer的问题,求高手解答!!!! JAVA核心技术 i+=j,i=i+j 效率讨论
Accept: */*
Accept-Language: zh-cn
ajaxrequest: true
__clienttype: unieap
resourceid: null
Content-Type: multipart/form-data
workitemid: null
Referer: http:///jwxt/forward.action?path=//xscj/xscjcx/xsgrcj_list
render: unieap
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Host:
Content-Length: 827
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=A7FEDF34AA0592503FDEBB10B1801CD1{header:{"code": -100, "message": {"title": "", "detail": ""}},body:{dataStores:{kccjStore:{rowSet:{"primary":[],"filter":[],"delete":[]},name:"kccjStore",pageNumber:1,pageSize:10,recordCount:11,rowSetName:"pojo_com.neusoft.education.sysu.xscj.xscjcx.model.KccjModel",order:"t.xn, t.xq, t.kch, t.bzw"}},parameters:{"kccjStore-params": [{"name": "Filter_t.pylbm_0.5561039376138874", "type": "String", "value": "'01'", "condition": " = ", "property": "t.pylbm"}, {"name": "Filter_t.xn_0.10712511051512274", "type": "String", "value": "'2010-2011'", "condition": " = ", "property": "t.xn"}, {"name": "Filter_t.xq_0.40865586464372716", "type": "String", "value": "'1'", "condition": " = ", "property": "t.xq"}, {"name": "xh", "type": "String", "value": "''", "condition": " = ", "property": "t.xh"}], "args": ["student"]}}}
写的时候直接写流,而不是写键值对
免得你到处找了:
httppost.setEntity(new StringEntity("你构造的JSON字符串"));
String a = "字符串";
try {
httpost.setEntity(new StringEntity(a));
response = httpclient.execute(httpost);
}是不是大题是这样?
__clienttype: unieap
resourceid: null
Content-Type: multipart/form-data
workitemid: null因为不知道对方会检查啥,所以看到长相奇特的都要引起注意。