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

今日调用一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

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

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

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

上一篇:Java 链接SQL Server 数据库


下一篇:Spring Security(15)——权限鉴定结构 RoleVoter