Java位运算的使用的问题。
下面是根据选中的checkbox通过位运算得到的一个十进制数的代码,我现在需要根据这个十进制数知道有哪些checkbox被选中,代码应该怎么写呢?请给出Java代码,感谢!
String [] checkValue= request.getParameterValues("listCheck");
int role=0;
for (int i = 0; i < checkValue.length; i++)
{
int a=Integer.parseInt(checkValue[i]);
role=a|role;
}
return role;
下面是jsp页面里的checkbox:
<td > <input type="checkbox" name="listCheck" value="1" id="checkboxid" />OPB数据分析 </td>
<td ><input type="checkbox" name="listCheck" value="2" id="checkboxid"/>OPS数据分析</td>
<td > <input type="checkbox" name="listCheck" value="4" id="checkboxid" />OPA数据分析</td>
<td> <input type="checkbox" name="listCheck" value="8" id="checkboxid"/>OPB转化率分析</td>
<td> <input type="checkbox" name="listCheck" value="16" id="checkboxid"/>激活数据分时段监控 </td>
<td> <input type="checkbox" name="listCheck" value="32" id="checkboxid"/>数据汇总管理</td>
<td><input type="checkbox" name="listCheck" value="128" id="checkboxid"/>第三方数据付费分析 </td>
<td><input type="checkbox" name="listCheck" value="256" id="checkboxid"/>应用包分析</td>
<td><input type="checkbox" name="listCheck" value="512" id="checkboxid"/>渠道数据分析</td>
<td ><input type="checkbox" name="listCheck" value="1024" id="checkboxid"/>服务器负载监控 </td>