我继承了一个使用码头的战争文件。我想禁用HTTP方法选项。
我对码头服务器不熟悉。请帮助我在步骤中禁用HTTP方法
这是标准Servlet规范支持的。
编辑战争的WEB-INF/web.xml
并针对url模式添加安全约束以拒绝使用OPTIONS
方法。
示例。
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- ... other configurations ... -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted HTTP 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>