Java服务启用不安全的http方法解决方式

如果启用了不必要的HTTP方法可能会带来安全问题,如果启用了不必要的HTTP方法可能会带来安全问题
请问有什么办法能禁用掉options方法?急!

img

单个应用禁用就修改自己的应用的web.xml,也可以修改tomcat的web.xml,效果就是整个tomcat下的应用都会禁用,具体修改如下:

在web.xml中插入以下内容:
<security-constraint>
    <web-resource-collection>
        <web-resource-name>fortune</web-resource-name>
        <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>

你可以在服务器写filter拒绝option请求。

这个不是已经有解决办法了吗?没有效果吗?

过滤器,拦截器,网关,或者不要引用第三方jar包,自己去实现servlet