0
以下curl
命令创建CRX一个节点:如何使CQ 5以JSON格式返回响应?
curl -u admin:admin \
-F”jcr:primaryType=nt:unstructured” \
-F”sling:resourceType=foo/bar” ... http://localhost:4502
然而CQ5返回HTML格式的响应:
<html>
<head>
<title>Content modified ...</title>
</head>
<body>
<h1>Content modified ...</h1>
...
<p><a href="">Go Back</a></p>
<p><a href="...">Modified Resource</a></p>
<p><a href="/etc/tags/...-keywords">Parent of Modified Resource</a></p>
</body>
</html>
有一种方法以工艺的要求,使得响应是JSON格式?
我不确定是否存在,但看起来上面页面中唯一真正有用的部分是状态码(在这种情况下是'201'),如果您没有在浏览器中查看它 - 错误页面是否提供了在JSON中需要的更多有用内容? – anotherdave
@anotherdave为了简化这个问题,我从上面的输出中排除了一些内容,但是响应包含一个'
回答
Apache Sling,在其上基于CQ,基于所请求的Accept报头输出格式:
这应该工作相同于CQ。
根据Sling的PostServletOutputContentTypeTest,您还可以使用
:http-equiv-accept
请求参数而不是Accept标头。来源
2014-07-21 09:24:23
相关问题