首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

用strust标签怎么获取Map 具体某个键的值,就像地图.get(key)

2013-07-11 
用strust标签如何获取Map 具体某个键的值,就像map.get(key)用strust标签如何获取Map 具体某个键的值,就像m

用strust标签如何获取Map 具体某个键的值,就像map.get(key)
用strust标签如何获取Map 具体某个键的值,就像map.get(key)
[解决办法]
我用JSTL c:标签获取过List对象,map不知道行不行!!!
不过你可以试试,我将代码给你。。

HttpServletResponse response = ServletActionContext.getResponse();      
    response.setCharacterEncoding("UTF-8"); 
    try {
    JSONArray result=JSONArray.fromObject(hashMap);
response.getWriter().write(result.toString());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
Struts.xml

<action name="loadByCalltor" class="com.web.hg.action.CalltorAction" method="loadByCalltor">
<result name="success">/pageJSP/cmonitor.jsp</result>

xx.jsp

<c:forEach items="${hashMap}" var="map">

        <c:out value="${map.key}" />

        <c:out value="${map.value}" />

     </c:forEach>



</action>

[解决办法]


<s:iterator value="testlist" var="testmap">
<s:iterator value="testmap">
  <s:property value="key" />
<s:property value="value" />
  </s:iterator>
</s:iterator> 


我记得应该是这样就可以了..
[解决办法]
<ww:property value="#map.key"/>  或 <ww:property value="#map.getKey('key')"/> 说明strus可以向直接调用方法的

热点排行