查看tomcat日志,发现有些请求方式是CONNECT、HEAD,不是正常的请求,决定禁掉这样的。在web.xml上加上下面代码可以禁掉这些请求方式,以这些方式请求服务tomcat将会返回403状态。
(加在tomcat/conf/web.xml下会对整个tomcat生效,加在单个项目下只会对这个项目生效)
<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> <http-method>CONNECT</http-method> </web-resource-collection> <auth-constraint></auth-constraint> </security-constraint>
时间: 2024-11-12 08:34:03