Spring MVC controller Test - print the result JSON String

前端 未结 5 2231
一向
一向 2021-01-30 05:03

Hi I have a Spring mvc controller

@RequestMapping(value = \"/jobsdetails/{userId}\", method = RequestMethod.GET)
@ResponseBody
public List jobsDetai         


        
5条回答
  •  忘了有多久
    2021-01-30 05:50

    For me it worked when I used the code below:

    ResultActions result =
         this.mockMvc.perform(post(resource).sessionAttr(Constants.SESSION_USER, user).param("parameter", "parameterValue"))
            .andExpect(status().isOk());
    String content = result.andReturn().getResponse().getContentAsString();
    

    And it worked !! :D

    Hope I can help the other with my answer

提交回复
热议问题