【问题标题】:Modify slinghttpresponse through wrapper通过wrapper修改slinghttpresponse
【发布时间】:2018-04-28 10:56:53
【问题描述】:

我正在尝试覆盖 AEM 中的默认发送重定向功能。

我想从我的服务器重定向到 https 网址。

同样,我已经实现了一个吊索过滤器。实现了 SlingHttpServletResponseWrapper 类并重写了 sendredirect 函数。

但是,在我尝试过滤时

最终的 SlingHttpServletResponse slingResponse = (ModifyLocResponse) 响应;

在运行时我得到

org.apache.sling.security.impl.ContentDispositionFilter$RewriterResponse 无法转换为 com.adobe.acs.samples.filters.wrappers.ModifyLocResponse

【问题讨论】:

  • 请添加ModifyLocResponse的代码和您使用它的过滤器。

标签: filter aem servlet-filters sling


【解决方案1】:

尝试通过以下方式实例化它,而不是强制转换:

final SlingHttpServletResponse slingResponse = new ModifyLocResponse(response);

当然,您需要确保该类的构造函数也具有这种模式:

class ModifyLocResponse extends SlingHttpServletResponseWrapper {
    public ModifyLocResponse(SlingHttpServletResponse response) {
        super(response);
    }
    ...
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-15
    • 2020-02-20
    • 1970-01-01
    • 1970-01-01
    • 2020-12-17
    • 2021-12-05
    • 2012-06-04
    相关资源
    最近更新 更多