这是我的职责
@RequestMapping(value = { "/showTaskMonitorStatus.do", "/showStatusPage.do" }, method = RequestMethod.GET)
public ModelAndView handleShowTaskMonitorStatus(HttpServletRequest request) {
ModelAndView model = new ModelAndView();
-----------------------------------
return model;
}我的测试用例看起来,
@Test
public void testHandleShowTaskMonitorStatus() throws Exception {
MvcResult result = mockMvc.perform(get("/showTaskMonitorStatus.do"))
.andDo(MockMvcResultHandlers.print()) // Print request and response
.andExpect(status().isOk())
.andExpect(content().contentType("application/json")) //but in this line I am getting error.(Content type not set.)
.andReturn();
--------------------------------------
}有人能建议我怎么解决这个问题吗?
发布于 2015-04-28 08:58:57
您可以像这样修改@RequestMapping以设置正确的内容类型:
@RequestMapping(value = { ... }, produces = MediaType.APPLICATION_JSON_VALUE)https://stackoverflow.com/questions/29914005
复制相似问题