您的位置:首页 > 其它

开发记录

2015-08-22 14:36 344 查看
1.controller没加载

<mvc:annotation-driven />

2.json-lib maven配置有问题

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.3</version>
<classifier>jdk15</classifier>
</dependency>

3."java.lang.AssertionError: Content type expected:<application/json> but was:<application/json;charset=UTF-8>?"

@Test
public void getJson() throws Exception {
ReqDataPage page = new ReqDataPage();
page.page = 1;
page.pageSize = 2;
JSONObject json = JSONObject.fromObject(page);

this.mockMvc.perform(post("/getJson")
.characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON)
.content(json.toString().getBytes())
).andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.msg").value("ok"));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: