我正在制作图像滑块,我想从服务器中提取图像名称。
对于动态,以下是我所拥有的。
<script type="text/javascript">
var firstreel=new reelslideshow({
wrapperid: "myreel", //ID of blank DIV on page to house Slideshow
dimensions: [800, 600], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
["http://www.almaktab.com/iPhoneApp/gallery/image001.jpg"], //["image_path", "optional_link", "optional_target"]
["http://www.almaktab.com/iPhoneApp/gallery/image002.jpg", "http://www.almaktab.com/iPhoneApp/gallery/image002.jpg", "_new"],
["http://www.almaktab.com/iPhoneApp/gallery/image003.jpg"],
["http://www.almaktab.com/iPhoneApp/gallery/image004.jpg"]
//-no trailing comma after very last image element!
],
displaymode: {type:'auto', pause:4000, cycles:2, pauseonmouseover:true},
orientation: "h", //Valid values: "h" or "v"
persist: true, //remember last viewed slide and recall within same session?
slideduration: 300 //transition duration (milliseconds)
})
</script>
现在我想imagearray
用我在数据库中的图像名称替换。
因此我所做的如下。
xmlns:c="http://java.sun.com/jsp/jstl/core"
<h:body>
<f:metadata>
// pulling image names
<f:event type="preRenderView" listener="#{FullScopeBens.pullMyImageNames()}"/>
</f:metadata>
<script type="text/javascript">
alert('perfect = ');
var data = {
<c:forEach items="${FullScopeBens.myDealsList}" var="ctag" varStatus="loop">
'${ctag.imagePath}': '${ctag.imagePath}${!loop.last ? ',' : ''}
</c:forEach>
};
alert('perfect = ' + data);
</script>
并计划更换imagearray:...
为imagearray:data
.
但它不起作用。
当我打印
<c:forEach items="#{FullScopeBens.myDealsList}" var="item">
${item.id}==${item.title}
</c:forEach>
我得到了该图像的正确 ID 和标题。
知道如何在 javascript 中获取图像路径。
即使我尝试了下面的链接。但仍然无法正常工作。
https://community.jboss.org/thread/160332
(寻找3. Dec 23, 2010 8:31 AM (in response to Eswara MoorthyNEC)
)
回答
下面的链接帮助我回答。