3

在 adobe AEM(又名 cq)中,对于给定的 url,是否可以查看正在调用的 jsp?

我们有示例代码,不是我们编写的,如果存在或不存在特定选择器,则匹配 2 组“base”jsp - 'm' 用于移动设备。如果移动或桌面设备正在请求,则在基本 jsp 中将变量设置为标记。

从那时起,不再使用其他选择器 - 只需检查变量以特别包含移动特定 jsp 与否。

与仅使用选择器来调用特定 jsp 不同的方法。

通过跟踪脚本分辨率,它有助于可视化和首次亮相,但这是基于 sling 的代码的常见模式吗?

4

3 回答 3

3

You can see details about the most recent requests in the Web Console, the Recent Requests tab ( http://localhost:4502/system/console/requests for a local author instance ).

The output is similar to the one below, and it should give you enough information

  0 (2013-09-14 21:36:20) TIMER_START{Request Processing}
  0 (2013-09-14 21:36:20) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
  0 (2013-09-14 21:36:20) LOG Method=GET, PathInfo=/.edit.html
  0 (2013-09-14 21:36:20) TIMER_START{ResourceResolution}
  1 (2013-09-14 21:36:20) TIMER_END{1,ResourceResolution} URI=/.edit.html resolves to Resource=JcrNodeResource, type=sling:redirect, superType=null, path=/
  1 (2013-09-14 21:36:20) LOG Resource Path Info: SlingRequestPathInfo: path='/', selectorString='edit', extension='html', suffix='null'
  1 (2013-09-14 21:36:20) TIMER_START{ServletResolution}
  1 (2013-09-14 21:36:20) TIMER_START{resolveServlet(JcrNodeResource, type=sling:redirect, superType=null, path=/)}
  1 (2013-09-14 21:36:20) TIMER_END{0,resolveServlet(JcrNodeResource, type=sling:redirect, superType=null, path=/)} Using servlet /libs/sling/servlet/default/edit.jsp
  1 (2013-09-14 21:36:20) TIMER_END{0,ServletResolution} URI=/.edit.html handled by Servlet=/libs/sling/servlet/default/edit.jsp
  1 (2013-09-14 21:36:20) LOG Applying Requestfilters
  1 (2013-09-14 21:36:20) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
  1 (2013-09-14 21:36:20) LOG Calling filter: org.apache.sling.explorer.post.POSTServletFilter
  1 (2013-09-14 21:36:20) TIMER_START{/libs/sling/servlet/default/edit.jsp#0}
  3 (2013-09-14 21:36:20) LOG Including resource JcrNodeResource, type=sling:redirect, superType=null, path=/ (SlingRequestPathInfo: path='/', selectorString='head', extension='html', suffix='null')
  3 (2013-09-14 21:36:20) TIMER_START{resolveServlet(JcrNodeResource, type=sling:redirect, superType=null, path=/)}
  3 (2013-09-14 21:36:20) TIMER_END{0,resolveServlet(JcrNodeResource, type=sling:redirect, superType=null, path=/)} Using servlet /libs/sling/servlet/default/head.jsp
于 2013-09-14T18:47:02.013 回答
0

正如@robert_munteanu 所示,系统控制台上的请求选项卡是跟踪请求处理的最佳位置

这是 Sling 应用程序中的常见习语。不同的 JSP 用于 GET/POST 请求、包含选择器的请求或具有不同扩展名的请求。

查看Sling Cheatsheet以了解其在高层次上的工作原理,或者查看 Sling ScriptSelectionTest单元测试,它探索了更广泛的用例。

于 2013-09-16T07:47:22.057 回答
0

您还可以使用ServletResolver服务找出哪个脚本或 servlet 将处理请求:

    Servlet servlet = servletResolver.resolveServlet(slingRequest);
    RequestUtil.getServletName(servlet);
于 2013-09-15T14:43:18.540 回答