今日调用一post方式提交的http接口,此接口在测试环境ip调用时无问题,但在生产环境通过域名调用时一直报如下错误:

java.io.IOException: Server returned HTTP response code: 411 for URL

java.io.IOException: Server returned HTTP response code: 411 for URL-LMLPHP

百度之后得到:在调用时,添加如下两行代码即可,今行文以记之:

   /*解决411*/
httpConnection.setRequestProperty("Content-Length","0");
DataOutputStream os = new DataOutputStream( httpConnection.getOutputStream() );
/*解决411*/

附解决方案链接:http://blog.csdn.net/pfyuit/article/details/8137777

05-08 08:35