当用户看到特定内容时,是否可以捕获页面的滚动事件?
当用户在Instant Articles页面上看到图像时,我们需要发送分析请求
我有以下服务:
@Component(
immediate = true,
metatype = true)
@Service
@Property(name = EventConstants.EVENT_TOPIC, value = {ReplicationAction.EVENT_TOPIC})
public class MyService implements EventHandler {
@Property
private static final String MULTI_PROPERTY = "config.multiproperty";
........
//another implementation
........
}
Run Code Online (Sandbox Code Playgroud)
我想MULTI_PROPERTY成为数组值,有可能使用像图像上的一组值:
怎么实现呢?
我有这个代码项目我在哪里mp3s从一个目录复制到另一个目录,然后用一个目录重命名random 4 letter string.我可以将文件复制到输出目录,但os.rename似乎删除了文件.
for c in dirContents:
print str(c)
filepath = os.path.join(outDir, c)
if (os.path.isfile(filepath)):
random = ''.join([choice(string.ascii_uppercase) for n in xrange(4)])
os.rename(filepath, random + '.mp3')
Run Code Online (Sandbox Code Playgroud)
在重命名功能中有什么我缺少的吗?
我有以下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。如何关闭此评论的插入?
我正在尝试使用以下sling servlet http://localhost:4502/sling/test-services/planet.html
但是,它给出了404错误,不知道我在这里做错了什么.
@Component
@Service(value=javax.servlet.Servlet.class)
@Properties({
@Property(name="service.description", value="HTML renderer for Planet resources"),
@Property(name="service.vendor", value="The Apache Software Foundation"),
@Property(name="sling.servlet.resourceTypes", value="sling/test-services/planet"),
@Property(name="sling.servlet.extensions", value="html"),
@Property(name="sling.servlet.methods", value="GET")
})
@SuppressWarnings("serial")
public class PlanetResourceRenderingServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
final ValueMap properties = request.getResource().adaptTo(ValueMap.class);
// TODO should escape output - good enough for our tests
final PrintWriter pw = response.getWriter();
pw.println(String.format("<html><head><title>Planet at %s</title></head><body>", request.getResource().getPath()));
pw.println(String.format("<p>Name: %s</p>", properties.get("name")));
pw.println(String.format("<p>Distance: %s</p>", properties.get("distance")));
pw.println("</body></html>");
pw.flush();
}
} …Run Code Online (Sandbox Code Playgroud)