Expand my Community achievements bar.

SOLVED

How to add path param to sling servlet url ?

Avatar

Former Community Member

How to add path param to sling servlet url ? 

eg, /services/demo/path/{var1}/{var2}.html

1 Accepted Solution

Avatar

Correct answer by
Level 10

I assume you are looking for a similar way to place variables in paths of a URL - like you can with Spring - ie:

 @RequestMapping(value = "/{id}/ViewMyForm.do", method = RequestMethod.POST)

However - in Sling - a Request Parameter syntax is as follows. 

Request Parameters

A request parameter is like an input to a function. If you know you have some kind of operation that occurs at /get/me/some/info.json, you can attach request parameters to your GET request URI to retrieve the output of that servlet. For example, /get/me/some/info.json?on=football tells the servlet that you want some information on football.

- See more at:

http://www.citytechinc.com/us/en/blog/2013/08/apache-sling-selectors-request-parameters.html

http://stackoverflow.com/questions/20984706/is-it-possible-to-place-variables-into-a-resource-path-w...

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

I assume you are looking for a similar way to place variables in paths of a URL - like you can with Spring - ie:

 @RequestMapping(value = "/{id}/ViewMyForm.do", method = RequestMethod.POST)

However - in Sling - a Request Parameter syntax is as follows. 

Request Parameters

A request parameter is like an input to a function. If you know you have some kind of operation that occurs at /get/me/some/info.json, you can attach request parameters to your GET request URI to retrieve the output of that servlet. For example, /get/me/some/info.json?on=football tells the servlet that you want some information on football.

- See more at:

http://www.citytechinc.com/us/en/blog/2013/08/apache-sling-selectors-request-parameters.html

http://stackoverflow.com/questions/20984706/is-it-possible-to-place-variables-into-a-resource-path-w...