Java 我在使用SpringMVC和改型2.0将文件上传到服务器时遇到了这个问题
这是我的后端方法Java 我在使用SpringMVC和改型2.0将文件上传到服务器时遇到了这个问题,java,spring-mvc,file-upload,retrofit2,Java,Spring Mvc,File Upload,Retrofit2,这是我的后端方法 @IsAdmin @RequestMapping(value = "/student/upload/file/{operation}/{format}/", method = RequestMethod.POST) public ResponseEntity<?> handleStudentFile(@PathVariable String operation, @PathVariable String format, @RequestParam("fil
@IsAdmin
@RequestMapping(value = "/student/upload/file/{operation}/{format}/",
method = RequestMethod.POST)
public ResponseEntity<?> handleStudentFile(@PathVariable String
operation, @PathVariable String format, @RequestParam("file")
MultipartFile file) {
return studentHandler.handleStudent(operation, format, file);
}
@Multipart
@POST("admin/student/upload/file/{operation}/{format}/")
Call<ServerResponse> uploadNew(@Path("operation") String
operation, @Path("format") String format, @PartMap Map<String,
MultipartBody> map);
Map<String, MultipartBody> map = new HashMap<>();
File file = new File(filePath);
MultipartBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(),
RequestBody.create(MediaType.parse("application/vnd.ms-excel"), file))
// .addFormDataPart("some-field", "some-value")
.build();
map.put("file\"; filename=\"" + file.getName() + "\"",
requestBody);
ApiCallService.action(getActivity(), map,
ACTION_UPLOAD_EXCEL);
@Multipart
@POST("admin/student/upload/file/{operation}/{format}/")
public Call<ServerResponse> upload(@Path("operation") String
operation, @Path("format") String format, @Part("file") RequestBody
file);
MultipartBody.Builder multiPartBody =new
MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(),
RequestBody.create(MediaType.parse("application/vnd.ms-excel"),
file));
ApiCallService.action(getActivity(),
multiPartBody.build(), ACTION_UPLOAD_EXCEL2);
org.apache.poi.openxml4j.exceptions.InvalidFormatException: Your
InputStream was neither an OLE2 stream, nor an OOXML stream