我有一个属性,其中包含内容文件中所需页面的路径
...
<some_block
...
sling:resourceType="some_path_to_some_component"
somePage="some_path_to_page"
.../>
...
Run Code Online (Sandbox Code Playgroud)
合适的HTL组件some-component.html
<div data-sly-use.some_model="org.example.SomeModel">
...
</div>
Run Code Online (Sandbox Code Playgroud)
和模型类SomeModel.java
package org.example;
...
import com.day.cq.wcm.api.Page;
...
@Model(adaptables = { SlingHttpServletRequest.class, Resource.class },
defaultInjectionStrategy = DefaultInjectionStrategy.REQUIRED)
public class RelatedContentBlock {
@ValueMapValue
private Page somePage;
...
}
Run Code Online (Sandbox Code Playgroud)
我可以轻松地获得使用所需的Page对象@Inject和@Via注释,但为什么我不能用抢吧@ValueMapValue注解?我试图使用所有可能的变体,包括via属性等.是的,我可以从pageManager获取它,但@ValueMapValue有什么问题?
提前致谢!