0
我有一个控制器方法,它接受包含json和二进制文件的多部分发布请求。这是它的工作,但我想摆脱明确的objectMapper.readValue()
电话。POST控制器中的JSON和MultipartFile
@PostMapping
public void createEmployee(@RequestParam("employee") String employee,
@RequestParam("cv") MultipartFile cv
) throws IOException {
Employee empl = objectMapper.readValue(employee, Employee.class);
service.createEmployee(empl, cv.getBytes());
}
我尝试另一种方式:
@PostMapping
public void createEmployee(@RequestPart("employee") Employee employee,
@RequestPart("cv") MultipartFile cv
) throws IOException {
service.createEmployee(employee, cv.getBytes());
}
但在这里我得到了码415: “内容类型 '应用程序/八位字节流' 不支持”。
尝试了这一点,但什么都没有改变。 –