我需要使用struts 2遍历一个hashmap,如果hashmap的值为true,则需要选中该复选框,否则请不要选中它。
我已经能够遍历地图,但是我无法在其中放入条件检查。如果hashmap的值为true,则需要选中复选框,如果为false,则需要保持未选中状态。如何在迭代器中使用if子句检查hashmap的值。
以下是我正在使用的代码段
testMap=new HashMap<String, String>();
testMap.put("1","true");
testMap.put("2","false");
============================================== ===============================
<struts:iterator value="testMap.entrySet()">
<input type="checkbox" name="abc" value='<struts:property value="%{value}"/>'>
<struts:property value="%{value}"/>
代码段/如何工作的示例
<struts:iterator value="testMap">
<struts:checkbox name="abc" value="%{value}"/>
<struts:property value="%{value}"/>
</struts:iterator>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句