如何禁止DELETE,PUT,OPTIONS,TRACE,HEAD等协议访问应用程序
发布网友
发布时间:2022-04-30 01:06
我来回答
共1个回答
热心网友
时间:2022-06-27 18:26
第一步:修改应用程序的web.xml文件的协议
<?xml version="1.0" encoding="UTF-8"?>
version="2.4">
第二步:在应用程序的web.xml中添加如下的代码即可
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
重新部署程序,重启tomcat即可完成