通过httpclient发送post请求到对方php系统,然后提示Submitted URI too large,请问那里错了

黄邱小鸟 2019-08-13 10:58:57
我们是java,对接的平台是php,之前考勤数据是可以的,今天我打开日志返回这样的错误
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Submitted URI too large!</title>
<link rev="made" href="mailto:postmaster@localhost" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>Submitted URI too large!</h1>
<p>


The length of the requested URL exceeds the capacity limit for
this server. The request cannot be processed.

</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:postmaster@localhost">webmaster</a>.

</p>

<h2>Error 414</h2>
<address>
<a href="/">localhost</a><br />
<span>Apache/2.4.18 (Win32) PHP/5.6.16</span>
</address>
</body>
</html>


这是我们httpclient工具类,编码方式是gb2312
public static String doPost(String urlString, Map<String, String> params, String encode){
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(urlString);
try {
Set<String> keys = params.keySet();
NameValuePair[] values = new NameValuePair[keys.size()];
int i = 0;
for(String key : keys){
NameValuePair v = new NameValuePair();
v.setName(key);
v.setValue(params.get(key));
values[i] = v;
i ++;

}
// 设置超时时间15s
client.getHttpConnectionManager().getParams().setConnectionTimeout(10000);
// 设置读取数据超时时间
client.getHttpConnectionManager().getParams().setSoTimeout(10000);// 设置读数据超时时间(单位毫秒)
client.getHttpConnectionManager().getParams().setMaxTotalConnections(500);
client.getHttpConnectionManager().getParams().setDefaultMaxConnectionsPerHost(50);
client.getHttpConnectionManager().getParams().setStaleCheckingEnabled(true);
method.getParams().setHttpElementCharset(encode);
method.getParams().setContentCharset(encode);
method.setRequestBody(values); // 使用 POST 方式提交数据
client.executeMethod(method); //返回的状态
String response = method.getResponseBodyAsString();
return response; //response就是最后得到的结果
} catch (Exception e) {
e.printStackTrace();
}finally{
if(method != null){
method.releaseConnection();
}
if(client != null){
((SimpleHttpConnectionManager)client.getHttpConnectionManager()).closeIdleConnections(0);
}
}

return "";
}

我们的参数格式这样的,可能个别字符长度不一致,结构是这样的。

我们也是post请求为什么会出现这个报错呢?
...全文
195 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
黄邱小鸟 2019-08-13
  • 打赏
  • 举报
回复
找到问题了,感觉自己好蠢,url是配置在配置文件中的,我用url = url + “”;这样只会造成url被持续拼接,蠢到无语了。
黄邱小鸟 2019-08-13
  • 打赏
  • 举报
回复
引用 1 楼 月光下的大D丶 的回复:
https://translate.google.cn/#view=home&op=translate&sl=en&tl=zh-CN&text=Submitted%C2%A0URI%C2%A0too%C2%A0large!

uri是对方的请求地址,也是对方提供的,这不可能出现问题的。
  • 打赏
  • 举报
回复
https://translate.google.cn/#view=home&op=translate&sl=en&tl=zh-CN&text=Submitted%C2%A0URI%C2%A0too%C2%A0large!

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧