后台代码是这样的
@At("/upLoadFiles")
@GET
@POST
@Ok("json")
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
public String upLoadFiles(@Param("file") File file,@Param("build_id") Integer build_id,@Param("filetype") String filetype,@Param("filename") String filename){
return "";
}
前端代码是这样的
var formdata=new FormData();
formdata.append("file",file);
formdata.append("build_id",this.buildingData.attributes.objectid);
formdata.append("filetype",fileType);
formdata.append("filename",file.name);
var req = new XMLHttpRequest();
req.open("POST", "../client/service/comPetingDataController/upLoadFiles", true);
req.send(formdata);
调试发现其他的参数接收都正常,但是file对象却始终是null,可以保证前端file对象是正常的