当我按下一个触发AJAX事件的按钮时,我想知道为什么我在Eclipse IDE中收到此异常:
无法读取HTTP消息:org.springframework.http.converter.HttpMessageNotReadableException:读取输入消息时出现I / O错误;嵌套异常是java.net.SocketTimeoutException
但是,如果我在Chrome中按F12,该程序将起作用。我在将AJAX请求传递给REST控制器时使用Spring Boot。
public ResponseEntity<?> readData(@RequestBody String string){
System.out.print(string);
FileProcessor fileProcessor = new FileProcessor();
fileProcessor.execute(string.split("\n"));
List<Record> records = fileProcessor.getRecords();
return new ResponseEntity<List<Record>>(records,HttpStatus.OK);
}
var ajaxRead = false;
if (window.XMLHttpRequest) {
ajaxRead = new XMLHttpRequest();
} else if (window.ActiveXObject) {
ajaxRead = new ActiveXObject("Microsoft.XMLHTTP");
}
if(ajaxRead) {
ajaxRead.open("POST","/readFile",true);
ajaxRead.send(verify + "\n" + data);
ajaxRead.onreadystatechange = function(){
if(ajaxRead.readyState === 4){
if(ajaxRead.status === 200){
alert("Success!");
}else
clearFile(ajaxRead.responseText);
}
}
}
}