我正在制作一个Web应用程序,它在spring mvc框架中使用tomcat服务器在报表处理中发送大量数据。我遇到的是,当交易大约300行时,它根本不发送。这是我的控制器:
@RequestMapping(value = "/save",method=RequestMethod.POST)
public @ResponseBody String saveForm(AbtractForm form,
HttpServletRequest request, BindingResult result){
String returnText="";
if(!result.hasErrors()){
try{
servicesInterface.saveFormImpl(form);
returnText = "ENTRY HAS BEEN SAVED";
}catch(Exception ex){
ex.printStackTrace();
System.out.println("Info log:"+ex.getMessage());
returnText = "INVALID ENTRY.CHECK LOG FOR MORE INFORMATION.";
}
}else{
returnText = "INVALID ENTRY.CHECK LOG FOR MORE INFORMATION.";
}
return returnText;
}
这是tomcat server.xml的配置
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" maxPostSize="-1" />
这是我发送数据的ajax函数:
$.ajax({
type: 'POST',
dataType:'JSON',
url: '/save',
data:$("#formID").serialize(),
async:false,
success:function(response){
if(response == "ENTRY HAS BEEN SAVED"){
$('#dataTable tbody tr').text("");
$("#done").attr("class","success");
}else{
$("#done").attr("class","error");
}
$("#load").hide();
$("#spanMessage").text(response);
},
error:function(er,st,th){
$("#spanMessage").text("ERROR FOUND");
$("#load").hide();
},
});
maxPostSize的Tomact服务器配置已设置为-1(无限制后最大大小),但它不起作用。当我发送数据少于200行时,它可以正常工作。我有一个事务的数组元素(表行)。这是我发现的错误:
Request Method:POST
Status Code:404 Not Found
请求标头:
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:149602
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:JSESSIONID=F6CF1C8FBC8144F94F50F0BC329E3C70
回复标题:
Cache-Control:no-cache
Cache-Control:no-store
Content-Language:en-US
Pragma:no-cache
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
我的控制器没有在log中抛出错误。但是当我少量发送数据时,控制器响应成功保存。有没有其他方法可以配置tomcat服务器的限制大小?
感谢。