【问题标题】:s:iterator over list of maps:迭代器在地图列表上
【发布时间】:2011-04-11 07:46:44
【问题描述】:

我有一张地图列表 - listMaps List<Map<String,Object>> 我想使用s:iterator 使用特定键值动态构建图像源

我尝试了以下方法,但没有得到任何结果

<s:iterator value="lastMaps" var="listMap" status="st">  
    test 1 <img src="<%=request.getContextPath()%>/image/%{#listMap.key}.jpg" />
    test 2 <img src="<%=request.getContextPath()%>/image/%{'lastMaps['+#st.index+'].key'}.jpg" />
    test 3 <img src="<%=request.getContextPath()%>/image/%{top['key']}.jpg" />
</s:iterator>

我查看了在 firebug 中解析的内容,我发现 %{''} 中的任何文本都没有被评估 - 甚至不是简单的文本

谢谢

【问题讨论】:

    标签: jsp struts ognl


    【解决方案1】:

    &lt;img src="&lt;%=request.getContextPath()%&gt;/image/&lt;s:property value="%{#listMap.key}"/&gt;".jpg" /&gt;

    等等 - 基本上,你忘记了评估的 s:property 标记。

    【讨论】:

    • 你刚刚拯救了我的一天,只需删除 '.jpg' 之前的双引号就可以了
    猜你喜欢
    • 2016-03-30
    • 2019-07-30
    • 2012-10-11
    • 2022-11-17
    • 2019-08-16
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多