@requestparam函数,例如request.getquerystring()。为什么@requestbody无法收到她的multipart / form-data类型的contentType?请告诉我为什么?
@PostMapping(value = "/uploadFileByUserTrainId", consumes = "multipart/form-data")
@Student({Student.Authority.A, Student.Authority.B, Student.Authority.C})
public WebMessage uploadFileByUserTrainId(
@RequestParam(value = "document", required = false) MultipartFile multipartFile,
@RequestParam(value = "documetnRe", required = false) MultipartFile multipartFileRe,
@RequestParam("id") long id,
@RequestParam(value = "documentFileType", required = false) String fileType,
@RequestParam(value = "documentFileReType", required = false) String fileReType,
HttpServletRequest httpServletRequest) {
// todo
}
答案 0 :(得分:1)
将@RequestParam
与Multipart file.
一起使用没错
@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor