[java] Tomcat does not support restful style put and delete requests by default

Tomcat does not support restful style put and delete requests by default

method one

Tomcat
default is to not allow PUT and DELETE.
How to configure Tomcat to support HTTP Delete and Put methods
Configure org.apache.catalina.servlets.DefaultServlet in tomcat web.xml file

readonly
false
readonly参数默认是true,即不允许delete和put操作,所以通过XMLHttpRequest对象的put或者delete方法访问就会报告http 403错误。为REST服务起见,应该设置该属性为false。

Method Two

HiddenHttpMethodFilter

在浏览器端的 Form 表单中只支持 GET、POST 请求,不支持 PUT、DELETE 请求。Spring 3.0增加了一个过滤器可以将 POST 请求转化为 PUT、DELETE 请求。

在 web.xnl 文件中配置 HiddenHttpMethodFilter 过滤器。

Guess you like

Origin www.cnblogs.com/iiiiiher/p/12689168.html