HTTP状态405-使用WebServices调用DELETE方法时,方法不允许错误 [英] HTTP Status 405 - Method Not Allowed Error on Invoking a DELETE method using WebServices

查看:733
本文介绍了HTTP状态405-使用WebServices调用DELETE方法时,方法不允许错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下@DELETE方法(使用Jersey框架(JAX-RS实现))从联系人"表中删除联系人"

I am trying to delete a "Contact" from the "Contacts" table using the following @DELETE method (using Jersey Framework (JAX-RS implementation)

@DELETE
@Path("/delete/{contact}")
public String deleteContact(@PathParam("contact") String name) throws ClassNotFoundException, SQLException {

    String response = DAOaccess.deleteContact(name);
    return response; 
}

以下URL用于从浏览器调用Web服务:

And the following url is used to invoke the webservice from the browser:

/联系人/删除/联系人姓名

但是这样会引发HTTP状态405-不允许的方法.

可能是什么原因?我该如何克服?

What might be the reason? How do I overcome this?

推荐答案

URL = /contacts/delete/contactname

405因为

似乎删除始终表现为submit (Post method) 并且您正在尝试像URL中的get方法那样进行调用. This is not possible to call the post method as like get. 如果您真的想通过浏览器调用此Web服务进行测试,只需下载Mozilla plugin (Poster),它将帮助您以所有方法类型提交Web服务.

It seems delete is always behave as submit (Post method) and you are trying to call as like get method from the URL. This is not possible to call the post method as like get. if you really want to call this web service from the browser to test, just download a Mozilla plugin (Poster) which will help you to submit the web service in your all method types.

这篇关于HTTP状态405-使用WebServices调用DELETE方法时,方法不允许错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆