---
title: "Tomcat中禁用OPTIONS/DELETE等"
author: "xuxujing"
date: "2014-11-19T09:49:41Z"
tags: []
categories: ["行业应用"]
slug: "tomcat-options-delete"
draft: false
lastmod: "2014-11-19T09:49:41Z"
id: 2157836
url: "https://xujava.iteye.com/blog/2157836"
---

测试：  
curl -v -X OPTIONS http://localhost:8080/a/

curl -v -X OPTIONS http://localhost:8080/b.jsp

Tomcat的Web.xml中添加如下配置：  
&lt;security-constraint&gt;  
 &lt;web-resource-collection&gt;  
 &lt;url-pattern&gt;/\*&lt;/url-pattern&gt;

 &lt;http-method&gt;PUT&lt;/http-method&gt;  
 &lt;http-method&gt;DELETE&lt;/http-method&gt;  
 &lt;http-method&gt;HEAD&lt;/http-method&gt;  
 &lt;http-method&gt;OPTIONS&lt;/http-method&gt;  
 &lt;http-method&gt;TRACE&lt;/http-method&gt;

 &lt;/web-resource-collection&gt;

 &lt;auth-constraint&gt;&lt;/auth-constraint&gt;

&lt;/security-constraint&gt;