如何在另一个吊索模型中适配 OOTB ContentFragmentList 吊索模型

问题描述

我正在尝试调整 OOTB ContentFragmentList 吊索模型,如下所示 -

@Model(adaptables = SlingHttpServletRequest.class,defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,resourceType = "myproject/components/slingTestModel")

public class SlingTestModel {

private static final Logger log = LoggerFactory.getLogger(SlingTestModel.class);

@Self(injectionStrategy = InjectionStrategy.required)
SlingHttpServletRequest slingHttpServletRequest;
@postconstruct
public void initModel() {
    log.debug("Inside sling model");
    ContentFragmentList ContentFragmentList = slingHttpServletRequest.adaptTo(ContentFragmentList.class);
    log.debug("sling model end");
}

}

它抛出以下异常 -

Caused by: java.lang.classCastException: com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.ContentFragmentListImpl 无法转换为 com.adobe.cq.wcm.core.components.models .contentfragment.ContentFragmentList

解决方法

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

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

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