我正在使用ExtJS 4
表单提交excel文件,但即使请求成功,它也会注册失败。什么是form.submit
功能期待看到?
形成
xtype: 'form',
name: 'upload_form',
items: [{
text: 'File Upload',
xtype: 'fileuploadfield',
name: 'upload_btn',
buttonOnly: true,
hideLabel: true,
allowBlank: false,
clearOnSubmit: false
}]
调节器
'filter fileuploadfield[name="upload_btn"]': {
change: this.UploadClick
}
...
UploadClick: function (vb, s) {
var controller = this,
form = controller.getUploadForm();
if (form.isValid()) {
form.submit({
url: '/upload',
waitMsg: 'Uploading your csv...',
success: function (fp, o) {
Ext.Msg.show({
title: 'Upload Complete',
msg: o.response.responseText,
icon: 'save-success',
buttons: Ext.Msg.OK
});
},
failure: function (fp, o) {
Ext.Msg.show({
title: 'Upload Error',
msg: o.response.responseText,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
});
}
}
Java回归
Response.ResponseBuilder builder;
...
builder = Response.ok(null);
return builder.build();
不发送null
Response ...但预期的JSON
以及适当的内容类型标题:
String json = "{\"success\": true}";
return Response.ok(json, MediaType.APPLICATION_JSON).build();
您需要在响应中附加参数success
:
E.g:
{
"success":true, // note this is Boolean, not string
"msg":"File uploaded"
}
如在文档中:https://docs.sencha.com/extjs/4.2.6/#!/api/Ext.form.Basic-method-submit