【发布时间】:2014-09-27 19:44:49
【问题描述】:
addVendorLicense:function(){
var self=this;
if(app.vendorId){
$('#licenseForm').ajaxSubmit({
url: "vendorLicense/create/"+app.vendorId,
async:false,
success: function (res) {
alert(res.message);
self.addLicenseRow();
},
error:function(res){
alert(res.message);
}
});
}
else{
alert("Please Add a vendor First");
}
return false;
},**
***Spring Controller***
@RequestMapping(value = "/create/{vendorId}", method = RequestMethod.POST)
public ResponseEntity<VendorLicenseResponse> createLicense(LicenseRequest licenserequest,@PathVariable("vendorId") String vendorId) {}
***Request Object***
public class LicenseRequest extends BaseRepresentation {
@JsonIgnore
private String licenseType;
private String licenseName;
private String licenseNumber;
@JsonIgnore
private String expirationDate;
@JsonIgnore
private List<String> statesCovered;
private String terms;
private String brokerNumber;
private String organizationId;
@JsonIgnore
private CommonsMultipartFile insuranceFiles;
}
我正在尝试将多部分表单数据映射到 LicenseRequest 对象。当使用文件提交表单时,会正确解析 rquest,但是当没有文件提交表单时,服务器会给出 400 错误请求错误。有人可以告诉我如何制作文件在 multipart/form-data 中是可选的。
【问题讨论】:
标签: ajax spring backbone.js multipartform-data ajaxform