0
我在我的Spring MVC的测试控制器:Spring MVC的控制器测试+ JSON响应错误
@Test
public void consultaPorIdJson() throws Exception{
mockMvc.perform(get("/timesheet/consultaporidjson/{id}", 1L))
.andExpect(status().isOk())
.andExpect(content().contentType(TestSupport.APPLICATION_JSON_UTF8))
.andExpect(content().string("{\"id\":1,\"latitude\":\"30.448660206791608\",\"longitude\":\"-44.29684999999995\"}"));
当我尝试运行我的测试,我得到一个错误:
java.lang.IllegalStateException: Cannot set error status - response is already committed
我认为这是约2k(我认为)的回应,但我不知道我该怎么办才能解决它:-(
我没有尝试用完我的测试,因为我没有做jsp。我没有使用jsp构建,我只放置了REST。当我试着在我的控制器中只返回“new MyClass()”时,测试运行没有问题。但是当我把我的物体充满时,我有这个问题。 – user812612
不需要jsp。它的一个休息网址,所以只需在浏览器中键入或使用邮递员。另外如果你显示你的控制器代码,那么这将有所帮助。 –