汗,最近在写一个网络的东西,里面要和linux apache服务器进行HTTP POST交互
同样的URL,在PC浏览器上访问没问题,可以得到返回XML,但在BB机器上得到错误页面。。。
google了一下,发现如果要对APACHE服务器POST发送参数,就必须要指定Content-Type, Content-Length
代码如下
m_connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded" );
m_connection.setRequestProperty("Content-Length", Integer.toString(dataToSend.length));
这样就OK了