Controller.java
@RequestMapping(value = "/listUsers", method = RequestMethod.POST)
public @ResponseBody String listUsers(
@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchFormDto dto) throws IOException {
List<UserInformationDto> users = null;
// some statements
}
ControllerTest.java
@Test
public void testListUsers() throws Exception {
this.mockMvc.perform(post("/superadmin/listUsers").contentType(MediaType.APPLICATION_JSON).content(createSearchFormDto("1","25")))
.andExpect(status().isOk());
}
这里我将@RequestBody(SearchFormDto)作为JSON发送。而且我也能够获得价值。它工作正常。
我想将@RequestBody(SearchFormDto)设为null。建议我一些想法。
提前致谢。