How to hit a servlet using selector when resourceType is a component I created which is not page | Adobe Higher Education
Skip to main content
Level 3
November 23, 2020
해결됨

How to hit a servlet using selector when resourceType is a component I created which is not page

  • November 23, 2020
  • 2 답변들
  • 10223 조회

I'm using AEM 6.3

My servlet config is

@Component(service= Servlet.class,
        property={
                Constants.SERVICE_DESCRIPTION + "=Example Servlet",
                "sling.servlet.methods=" + HttpConstants.METHOD_GET,
                "sling.servlet.resourceTypes="+ "my-project/components/general/my-component ",
                "sling.servlet.extensions=" + "html",
                "sling.servlet.selectors=" + "simple"

        })

As you can see I'm not using a page as a resourceType so I'm a little confused. Can anyone tell me what will be the url to hit on browser so it runs my doGet Method. And yes My servlet works as I have tested it by giving path.

이 주제는 답변이 닫혔습니다.
최고의 답변: Anudeep_Garnepudi

Hi @vinit_pillai 

Drop my-component in any page and hit that path along with extension and selector with which you registered Servlet. For example

  1. Create a page with name test-page
  2. Drop my-component in that page
  3. copy that path i.e /content/your-project/test-page/par/my-component.selector.extension and hit from browser

selector and extension must be same as you provided in 

sling.servlet.extensions
sling.servlet.selectors

 

2 답변

Anudeep_Garnepudi
Community Advisor
Community Advisor
November 23, 2020

Hi @vinit_pillai 

Drop my-component in any page and hit that path along with extension and selector with which you registered Servlet. For example

  1. Create a page with name test-page
  2. Drop my-component in that page
  3. copy that path i.e /content/your-project/test-page/par/my-component.selector.extension and hit from browser

selector and extension must be same as you provided in 

sling.servlet.extensions
sling.servlet.selectors

 

Vinit_Pillai작성자
Level 3
November 23, 2020
http://localhost:4502/editor.html/content/my_project/homepage/profile-page/test/en.html this is my page when I edit it and add my component. by your suggestion the url will be http://localhost:4502/content/my-project/homepage/profile-page/test/en/par/my-component.selector.extension by hitting this I'm getting 404. am I doing something wrong?
Ankur_Khare
Community Advisor
Community Advisor
November 23, 2020

Create a page and add ur component on that page, try to access that page with selectors and extension.

like-

https://localhost:4502/content/simpleproject/test.simple.html