AEM将html信息注释插入json

AEM将html信息注释插入json,json,aem,Json,Aem,我有以下jsp <% JSONObject jsonResult = new JSONObject(); response.setContentType("application/json"); String parentNodePath = slingRequest.getRequestPathInfo().getResourcePath(); String url = getServerBaseUrl(sling) + parentNodePath.sp

我有以下jsp

<%
    JSONObject jsonResult = new JSONObject();
    response.setContentType("application/json");
    String parentNodePath = slingRequest.getRequestPathInfo().getResourcePath();
    String url = getServerBaseUrl(sling) + parentNodePath.split("/jcr:content")[0] + ".html?cid=twitter";
    UrlShortener urlShortener = sling.getService(UrlShortener.class);
    String shortUrl = urlShortener.shorten(url);
    String encShortUrl = URLEncoder.encode(shortUrl);
    jsonResult.put("url", url);
    jsonResult.put("shortUrl", shortUrl);
    jsonResult.put("encShortUrl", encShortUrl);
%>
<%=jsonResult.toString()%>

在浏览器中键入以下地址时执行

如您所见,我有“application/json”contentType。结果必须仅包含json信息,但有html注释:

{
    "url":"http://servername/content/app/test/test1/naps1.html?cid=twitter",
    "shortUrl":"http://servername/1E4sZYJ",
    "encShortUrl":"http%3A%2F%2Fservername%2F1E4sZYJ"
}
<!--
    cq{
        "decorated":false,
        "type":"app/components/page/newsarticlepage",
        "path":"/content/app/test/test1/naps1/jcr:content",
        "selectors":"urlshortener",
        "servlet": "Script/apps/app/components/page/contentpage/urlshortener.html.jsp","totalTime":276,"selfTime":276
    }
-->
{
“url”:”http://servername/content/app/test/test1/naps1.html?cid=twitter",
“短URL”:http://servername/1E4sZYJ",
“encShortUrl”:“http%3A%2F%2Fservername%2F1E4sZYJ”
}
我还看到,这些注释插入到每个组件之后,或者在任何页面中执行jsp。
如何关闭此注释的插入?

注释是为创作界面添加的。它们不包括在禁用wcmmode的发布实例中。您可以通过将
wcmmode=disabled
作为查询参数添加到url的末尾来看到这一点。您还必须从url中删除
cf#
editor.html

为创作界面添加注释。它们不会出现在出版物上。将wcmmode=disabled作为查询参数添加到url的末尾,注释应该会消失。此外,我还找到了另一种解决方案:在请求url中使用path/to/page/jcr:content.urlshortener.html而不是path/to/page.urlshortener.html