【问题标题】:How to Disable HTTP Method (OPTIONS, HEAD, ...) In GlassFish 3.1 Server如何在 GlassFish 3.1 Server 中禁用 HTTP 方法(OPTIONS、HEAD、...)
【发布时间】:2018-06-06 17:44:37
【问题描述】:

我希望在 GlassFish 3.1 服务器中禁用未使用的 HTTP 方法,例如 OPTIONS、HEAD。
谢谢。

更新:
目前,我已经实现了一个过滤器来检查请求的 HTTP 方法,并拒绝不支持的方法。当我说,

response.sendError(HttpServletResponse.SC_NOT_FOUND);

响应包含标头

Allow: TRACE, OPTIONS

我的应用程序不支持。

【问题讨论】:

    标签: glassfish-3 http-method


    【解决方案1】:

    将以下配置添加到您的应用程序 web.xml 文件中。

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    
        <security-constraint>
            <web-resource-collection>
                <web-resource-name>                
                </web-resource-name>
                <url-pattern>/*</url-pattern>
                <http-method>OPTIONS</http-method>
                <http-method>HEAD</http-method>
            </web-resource-collection>
            <auth-constraint />
        </security-constraint>
    
    </<web-app>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      • 2021-01-28
      • 2018-03-07
      • 2017-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多