您应该将内容类型添加
MediaType.APPLICATION_JSON到发布请求中,例如
this.mockMvc.perform(post("/rest/tests/") .contentType(MediaType.APPLICATION_JSON) .content("{"id":10,"width":1000}")) .andDo(MockMvcResultHandlers.print()) .andExpect(status().isOk());
您应该将内容类型添加
MediaType.APPLICATION_JSON到发布请求中,例如
this.mockMvc.perform(post("/rest/tests/") .contentType(MediaType.APPLICATION_JSON) .content("{"id":10,"width":1000}")) .andDo(MockMvcResultHandlers.print()) .andExpect(status().isOk());