Java – cq5 – sling CurrentPage in model class
•
Java
In CQ JSP, just call CurrentPage Getpath () can easily access the CurrentPage object But I'm trying to delete any scripts and separate them into model classes, and I can't figure out how to access the CurrentPage object I thought I could do this:
public void setResource(Resource resource){ resource.getPath() }
But this returns something like:
/content/home/subPage/jcr:content/banner
I just want to return / content / home / subpage / I'm trying to use resources to get the path, but I can't find anything that can do this I know it must be a small thing. I'm just looking down Thank you for your help!
Solution
You are getting JCR: content / banner because you are calling the resources of the internal components of the page, not the page itself
To get the current page from the component, you can use pagemanager:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码