解决办法:
ajax添加timeout时长,60000为60秒
$.ajax({
timeout: 60000,
url: xxxxxxxxx,
type: "post",
success: function(data) {
xxxxxxxxxxx
}
});
tomcat配置文件bin/server.xml里connector标签添加keepalive属性,maxKeepAliveRequests为支持最大请求数,超过的请求数将关闭,-1表示没有限制,keepAliveTimeout表示超时时长,60000为60秒
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="60000"
redirectPort="8443"
maxKeepAliveRequests="-1"
keepAliveTimeout="60000"/>
*注意协议版本:HTTP/1.1
本文介绍了如何通过设置Ajax请求的timeout属性来控制请求超时时间,以及在Tomcat的server.xml中调整connector标签的keepAlive属性和maxKeepAliveRequests属性,以优化服务器的连接管理和超时策略。通过这些配置,可以更好地管理长时间运行的请求,避免资源占用并提升系统性能。
3853

被折叠的 条评论
为什么被折叠?



