阻止 web.xml 中的一些 HTTP 方法

问题描述

我在单个 tomcat 中运行两个 war 文件。示例 app1 和 app2。现在我想单独阻止app2的一些HTTP方法而不触及tomcat自己的web.xml。所以我为 app2 创建了一个 web.xml 并将其放在 WEB_INF 下。

<web-app>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>restricted methods</web-resource-name>
            <url-pattern>/*</url-pattern>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>
</web-app>

当我将 URL 设为 host:port/app2/ 时,它会给出 403 响应。 但是当我点击 host:port/app2 时得到 200 的响应。

现在我也必须屏蔽 host:port/app2 这个 URL。如何更改 url-pattern 以实现此目的。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)