我有以下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()%>
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中输入以下地址http://servername:port/path/to/page.urlshortener.html.jsp时它会执行
如您所见,我有“应用程序/json”内容类型。结果必须只包含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
}
-->
Run Code Online (Sandbox Code Playgroud)
我也看到,这个注释插入在每个组件之后,或者在任何页面中执行 jsp。如何关闭此评论的插入?
<!-- cq{ ... } -->为创作界面添加了注释。它们不包含在禁用 wcmmode 的发布实例中。您可以通过wcmmode=disabled在 url 末尾添加查询参数来查看这一点。此外,您还必须从 url 中删除cf#或editor.html。
| 归档时间: |
|
| 查看次数: |
879 次 |
| 最近记录: |