我面临一个奇怪的问题.当我向类路径添加一些外部JAR时,我收到错误"它是从所需的.class文件间接引用的".但当我删除所有这些时,我摆脱了这个错误.这里是.classpath的条目
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="bundle/src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/external_jars/cq-wcm-api-5.7.8.jar"/>
<classpathentry kind="lib" path="C:/external_jars/cq-wcm-commons-5.7.8.jar"/>
<classpathentry kind="lib" path="C:/external_jars/cq-wcm-core-5.7.116.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Run Code Online (Sandbox Code Playgroud)
如果我需要提供任何其他信息,请告诉我.
提前致谢
这是我现在正在处理的一段类似的代码:
<div class="gallery-category">
<h2 data-gallery="Exterior">
<span class="gallery-back"></span>
Exterior
</h2>
<div class="gallery-items-wrap">
<div class="gallery-image-tile">
<div class="gallery-img" data-analytics="photo-click">
<picture>
<source srcset="/content/image/image1.jpg">
</picture>
</div>
</div>
</div>
</div>
<div class="gallery-category">
<h2 data-gallery="Interior">
<span class="gallery-back"></span>
Interior
</h2>
<div class="gallery-items-wrap">
<div class="gallery-image-tile">
<div class="gallery-img" data-analytics="photo-click">
<picture>
<source srcset="/content/image/image2.jpg">
</picture>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Exterior如果我点击图像,我必须获得价值image1.jpg。我创建了数据属性data-gallery并试图通过使用$('[data-gallery]').data("gallery")但只获取第一个值来获取值。
我需要的是这样的:
单击image1获取值“外部”。
单击image2获取值“内部”。
提前致谢
我创建了一个sling:OsgiConfig节点,它具有String []类型的属性路径.我需要在java类中访问此属性.我想在java类中创建一个我可以从JSP调用的方法.我正在使用taglib这样做.我知道我们可以使用下面的代码在JSP中实现相同的目标:
Configuration conf = sling.getService(org.osgi.service.cm.ConfigurationAdmin.class).getConfiguration("Name of the config");
String[] myProp = (String[]) conf.getProperties().get("propertyPath");
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Java类中执行此操作.
这是一段代码:
if (lastPosition == 0) {
callsomemethod(param);
}
Run Code Online (Sandbox Code Playgroud)
我有这种奇怪的情况,其中我必须调用函数callsomemethod(param); 即使if条件不止一次也是如此.换句话说,我想确保函数callsomemethod只被调用一次,即使if语句是多次为真.if语句中发生了更多的事情,为了简单起见,我刚把它们拿出来.
编辑::感谢所有的回复.不幸的是,这个方法都没有工作,因为if语句在函数内部,并且该函数被多次调用,所以一切都会再次初始化.该功能也在IIFE中.在第一次拍摄中没有让一切清晰的道歉.
提前致谢