I have the following servlet that works great
@component(
service=Servlet.class,
property= {
"sling.servlet.resourceTypes="+"mysite/components/structure/page",
"sling.servlet.selectors="+"testselector",
"sling.servlet.extensions="+"json",
ServletResolverConstants.SLING_SERVLET_METHODS + "=GET"
}
)
public class TestServlet extends SlingSafeMethodsServlet
I can call it using jquery ajax on a page like this
$.ajax({
type:"GET",
url: "/_jcr_content.testselector.json",
success: function(data){
console.log("success!")
}
});
I can also put the full address to the servlet in my browser (if i'm logged into my local aem instance) and get a valid response.
But if I create a second servlet that is almost identical like this:
@component(
service=Servlet.class,
property= {
"sling.servlet.resourceTypes="+"mysite/components/structure/page",
"sling.servlet.selectors="+"testselectortwo",
"sling.servlet.extensions="+"json",
ServletResolverConstants.SLING_SERVLET_METHODS + "=GET"
}
)
public class TestServletTwo extends SlingSafeMethodsServlet
then any calls to TestServletTwo return 400 Bad Request and in the browser, shows the error "Invalid recursion selector value testselectortwo".
Why isn't the second one working?