내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

How to programmatically find out the Resource given a URL?

Avatar

이전 커뮤니티 멤버

According to ResourceResolver Interface:

http://dev.day.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource/ResourceResolver.html

There are ways to resolve either path or request to a Resource:

     Resource   resolve(HttpServletRequest request) Deprecated. as of 2.0.4, use resolve(HttpServletRequest, String) instead. Resource   resolve(HttpServletRequest request, String absPath) Resolves the resource from the given absPath optionally taking HttpServletRequest into account, such as the value of the Host request header. Resource   resolve(String absPath) Resolves the resource from the given absolute path.

But, if I have a random given URL string (e.g. 'http://www.mycompany.com/whatever.html'). How do I programmatically find out the corresponding Resource from a given URL string?

In other words, how is 

Adobe Experience Manager Web Console
Sling Resource Resolver

implemented?

 
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee

Hi,

If you look at the code Joerg pointed to, you'll see how to do this - generate a synthetic HttpServletRequest object.

Regards,
Justin

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Employee Advisor

Avatar

이전 커뮤니티 멤버

Not really.

All the codes indicate given a request (e.g. HttpServletRequest) I can call ResourceResolve.resolve(request) to programmatically translate a Request to Resource. However, if I don't have a Request, but only a URL String, how do I figure out the Resource of a random given URL String?

Thanks,

Avatar

정확한 답변 작성자:
Employee

Hi,

If you look at the code Joerg pointed to, you'll see how to do this - generate a synthetic HttpServletRequest object.

Regards,
Justin