67,515
社区成员
发帖
与我相关
我的任务
分享
public String execute(){
HttpServletResponse response = ServletActionContext.getResponse();
List roleIds = userRoleBiz.findByUserId(Long.parseLong(uid));
List list = roleBiz.findAll();
List newList = new ArrayList();
for(int i=0;i<list.size();i++){
Map map = new HashMap();
TRole role = (TRole)list.get(i);
map.put("id",role.getId());
map.put("leaf",true);
map.put("text",role.getRolename());
if(roleIds.contains(role.getId())){
map.put("checked",true);
}else{
map.put("checked",false);
}
newList.add(map);
}
response.setContentType("text/json;charset=utf-8");
JSONArray ja = JSONArray.fromObject(newList);
try {
response.getWriter().print(ja);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}