コミュニティアチーブメントバーを展開する。

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

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Purpose of SlingHttpServletRequest as adaptables in Sling model

Avatar

Level 1

I am not able to understand when to use 'SlingHttpServletRequest' and 'Resource' as adaptables in sling model. Can someone please clarify my doubts ?

1 受け入れられたソリューション

Avatar

正解者
Community Advisor

When you want to interact with something in OSGi using a servlet or obtain something from the incoming request, you can go for SlingHttpServletRequest. When the interaction is purely with AEM resource you can go for Resource.

As mentioned in the documentation , using SlingHttpServletRequest, you can still get the resource something along the lines of request.getResource():

@Model(adaptables=SlingHttpServletRequest.class) public interface MyModel

// will return request.getResource().getValueMap().get("propertyName", String.class) @Inject @Via("resource") String getPropertyName(); }

元の投稿で解決策を見る

1 返信

Avatar

正解者
Community Advisor

When you want to interact with something in OSGi using a servlet or obtain something from the incoming request, you can go for SlingHttpServletRequest. When the interaction is purely with AEM resource you can go for Resource.

As mentioned in the documentation , using SlingHttpServletRequest, you can still get the resource something along the lines of request.getResource():

@Model(adaptables=SlingHttpServletRequest.class) public interface MyModel

// will return request.getResource().getValueMap().get("propertyName", String.class) @Inject @Via("resource") String getPropertyName(); }