The fact that SlingServletPaths is plural implies we can add more than one. However, the syntax seems to be undocumented. I have tired the following:
value = "/some/path1,/some/path2")
value = "[/some/path1,/some/path2]")
neither works, only if there is one or the other does it work (for that path)
Any ideas?
@Slf4j
@Component(service = {Servlet.class})
@SlingServletPaths(value = "/some/path1")
public class SomeServlet extends SlingAllMethodsServlet {
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @TB3dock,
According to documentation:
value param expects array of String, where each element in array represents single path.
This is the example how you can use it :
@Component(service = { Servlet.class })
@SlingServletPaths(value = {"/bin/path1", "/bin/path2"})
public class PathsServlet extends SlingAllMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse resp) throws ServletException, IOException {
// place for your code
}
}
Hi,
Could you check the same with below format ?
@component(service=Servlet.class,
name="Sample Servlet",
property={
"sling.servlet.methods=" + HttpConstants.METHOD_POST,
"sling.servlet.paths="+ "/bin/path1",
"sling.servlet.paths="+ "/bin/path2"
})
Thanks,
Somen
@TB3dock It can be done with the following code
@Component( service = {Servlet.class}, property = { "sling.servlet.paths=/bin/aem-integration/tasks", "sling.servlet.paths=/bin/aem-integration/files", "sling.servlet.extensions=json", "sling.servlet.methods=GET" } ) public class RunModeServlet extends SlingAllMethodsServlet {
Please refer to below thread for more information
Hope it helps!!
Hi @TB3dock,
According to documentation:
value param expects array of String, where each element in array represents single path.
This is the example how you can use it :
@Component(service = { Servlet.class })
@SlingServletPaths(value = {"/bin/path1", "/bin/path2"})
public class PathsServlet extends SlingAllMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse resp) throws ServletException, IOException {
// place for your code
}
}