Jsp 在struts 2中迭代hashmap,并根据其值检查或取消选中复选框
我需要使用struts 2对hashmap进行迭代,如果hashmap的值为true,我需要选中复选框,否则保持未选中状态 我已经能够在映射上进行迭代,但我不能在其中放入条件检查。如果hashmap的值为true,我需要选中复选框。如果为false,我需要保持未选中状态。如何在迭代器中使用if子句检查hashmap的值 下面是我正在使用的代码片段Jsp 在struts 2中迭代hashmap,并根据其值检查或取消选中复选框,jsp,checkbox,struts2,hashmap,Jsp,Checkbox,Struts2,Hashmap,我需要使用struts 2对hashmap进行迭代,如果hashmap的值为true,我需要选中复选框,否则保持未选中状态 我已经能够在映射上进行迭代,但我不能在其中放入条件检查。如果hashmap的值为true,我需要选中复选框。如果为false,我需要保持未选中状态。如何在迭代器中使用if子句检查hashmap的值 下面是我正在使用的代码片段 testMap=new HashMap<String, String>(); testMap.put("1","true"); testM
testMap=new HashMap<String, String>();
testMap.put("1","true");
testMap.put("2","false");
testMap=newhashmap();
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>
为什么不使用struts:checkbox
?checkbox很好,但问题是当hashmap的值为true时,如何有条件地将checked=“checked”子句放入复选框struts将根据value属性放置该子句。能否提供代码段/它将如何工作的示例?