谁能告诉我正确的方式开始,配置以及做CRUD操作的吊索。我遵循了下面的教程,但它不适用于CRUD。
http://sling.apache.org/documentation/getting-started/discover-sling-in-15-minutes.html
有没有人可以分享一下Sling框架的经验?
只允许有经验的人(谁曾与吊索)。
发布于 2015-01-07 22:02:16
CRUD操作是通过HTTP请求完成的。我将在我的示例中使用curl,并在http://localhost:8080/content/mynode的一个节点上操作,因为这就是在the tutorial you have read中使用的。
Create:要创建内容,需要执行HTTP POST请求。在本教程中,使用了以下示例:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some title" http://localhost:8080/content/mynode这将使用单个属性title=some title在http://localhost:8080/content/mynode中创建新内容
Read:简单地向内容节点发送GET请求:
curl http://localhost:8080/content/mynode..。或者更简单,使用web浏览器并导航到http://localhost:8080/content/mynode
Update:您还可以使用POST请求进行更新,例如:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some other title" http://localhost:8080/content/mynode这会将已经存在的内容节点的标题设置为some other title。您还可以添加新属性:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"myProperty=my value" http://localhost:8080/content/mynode..。这将添加值为my value的属性myProperty。
D HTTP :通过发送 delete请求来删除内容节点:
curl -u admin:admin -X DELETE http://localhost:8080/content/mynode有关您可以执行的全部操作,请参阅Apache Sling: Manipulating Content - The SlingPostServlet
发布于 2016-01-09 22:34:45
除了Vidar S.Ramdal所说的之外,您还可以利用作为OSGi服务提供的Java在Java语言中实现CRUD操作。这是以编程方式创建内容的一般方法。如果出于某种原因必须进行例外处理(例如,旧的Sling版本),则可以使用Java( JSR 170 Content Repository)。
使用adapters,您可以轻松地将资源(表示内容的代码套索类型)转换为节点。
发布于 2018-02-07 00:18:02
这在很大程度上取决于你真正想做的事情。例如,如果你想让你的终端用户选择在你的博客文章中写一条评论。您可以使用以下表单。
<form method="POST" action="/content/current/post/path" >
<input type="text" name="headline" value="" />
<input type="text" name="text" value="" />
</form>另一种选择是通过使用post引擎进行内容操作,就像上面已经描述的其他引擎一样。
您还可以通过使用ResourceResolver按路径解析资源来使用Java代码。https://sling.apache.org/documentation/tutorials-how-tos/getting-resources-and-properties-in-sling.html另一个选项是通过resource.adaptTo(Node.class)直接使用存储库中的节点
BR时间
https://stackoverflow.com/questions/27484902
复制相似问题