1.delete接口发布
/**
* delete请求
* @param deleteString
* @return
*接口路径在shiro中不做校验登录
*/
@ResponseBody
@RequestMapping(value="deleteTest",method =RequestMethod.DELETE)
public String deleteTest (@RequestParam String deleteString ){
System.out.println(deleteString);
return "success";
}
2.delete接口test对接
@Test
public void testDelete(){
String responseMsg = "";
HttpClient httpClient =new HttpClient();
httpClient.getParams().setContentCharset("UTF-8");
DeleteMethod deleteMethod = new DeleteMethod("http://localhost:8080/mycrm/mobileWorksheet/deleteTest?deleteString=22");
try {
httpClient.executeMethod(deleteMethod);
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = deleteMethod.getResponseBodyAsStream();
int len = 0;
byte[] buf = new byte[1024];
while((len=in.read(buf))!=-1){
out.write(buf, 0, len);
}
responseMsg = out.toString("UTF-8");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
deleteMethod.releaseConnection();
}
System.out.println("responseMsg---"+responseMsg);
}