我正在尝试调整 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");
}
}
它抛出异常 -
原因:java.lang.ClassCastException: com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.ContentFragmentListImpl 无法转换为 com.adobe.cq.wcm.core.components.models.contentfragment。内容片段列表