我正在开发包含某种基于 Web 的 XML 编辑器的 Web 应用程序。基本上我使用 html textarea 作为我的“编辑器”,当用户单击“保存”按钮时,包含修改过的 XML 的 AJAX 发布请求被发送到服务器。我使用 $.ajax 函数
function saveXML(){
var cm = editor.mirror;
var textXML = cm.getValue(); // textXML is a String representing edited XML
$.ajax({
url: "saveEditedBatch",
data: {xmlString: textXML},
type: 'POST',
success : function(response){
},
error : function (){
alert("error");
}
});
在服务器端我有控制器
@RequestMapping(value = "/saveEditedBatch", method = RequestMethod.POST)
public @ResponseBody JsonResponse saveEditedBatch(@RequestParam(value = "xmlString") String xmlString){
JsonResponse response = new JsonResponse();
byte[] byteXML = xmlString.getBytes();
byteXML = xmlAccess(new ByteArrayInputStream(byteXML));
// do something with byteXML
return response;
}
当我的 XML 以及我发送到服务器的字符串很小时 - 一切正常。但是,当 XML 很大时 - 我得到“HTTP 状态 400 - 所需的字符串参数 'xmlString' 不存在”,即使我知道我正在传递它。我能做些什么?