我的测试
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
byte[] bytes = objectMapper.writeValueAsBytes(webFile);
this.mockMvc.perform(post("/loadFile.json").accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).content(bytes)).andExpect(status().isOk());
我的控制器
@RequiredPermission(RequiredPermission.OperationType.viewProject)
@RequestMapping(value = "/loadFile", method = RequestMethod.POST)
public
@ResponseBody
ModelAndView load(@RequestBody WebFile document)
{ ... }
但总是得到 400 错误