我想知道是否可以将PUT,DELETE请求(实际上)发送java.net.HttpURLConnection到基于HTTP的URL。我已经读了很多描述如何发送GET,POST,TRACE,OPTIONS请求的文章,但是我仍然没有找到成功执行PUT和DELETE请求的示例代码。
3 回答

UYOU
TA贡献1878条经验 获得超4个赞
这对我来说是这样的:
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
int responseCode = connection.getResponseCode();
添加回答
举报
0/150
提交
取消