Access request query string parameter in Sightly component | Community
Skip to main content
Level 3
October 16, 2015
Solved

Access request query string parameter in Sightly component

  • October 16, 2015
  • 8 replies
  • 16237 views

How do I access a request query string parameter in Sightly HTML. Do I have to expose it through the WCMUse model or can I just access it directly in the HTML?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

You can use the following:

${request.requestParameterMap['test'][0].toString}

With http://server:port/resource?test=hello, then the output is ‘hello’

8 replies

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

You can use the following:

${request.requestParameterMap['test'][0].toString}

With http://server:port/resource?test=hello, then the output is ‘hello’

francisco_ribei
Level 6
October 16, 2015

Once you have the SlingHttpRequest object you can get the parameters using request.getParameter method.

Have you tried that?

Level 3
October 16, 2015

These are request attributes, not query string attributes e.g. getParameter. How do I get a query string parameter e.g. ?query=some+query

smacdonald2008
Level 10
October 16, 2015

See this Blog that talks about Sightly:

http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-4/

This talks about how to access the para­me­ters.

Feike_Visser1
Adobe Employee
Adobe Employee
February 11, 2018

Please note that there is an issue with this since AEM6.3+SP1+CFP1 (AEM6.3.1.1)

Workaround here: htl-examples/request-parameter.html at master · heervisscher/htl-examples · GitHub

Level 2
November 12, 2018

Try this:

${request.parameterMap.test}

Feike_Visser1
Adobe Employee
Adobe Employee
November 13, 2018
Level 2
August 28, 2019

Is it possible to return all the query string parameters? Similar to javascript window.location.search. Eg: current page url is https://google.com?utm_source=search&utm_media=online&param3=xxx and the expected return string is ?utm_source=search&utm_media=online&param3=xxx