List result 里面的值是[{N_SELF_CUST_PRIVILEGE_ID=7}, {N_SELF_CUST_PRIVILEGE_ID=8}, {N_SELF_CUST_PRIVILEGE_ID=9}, {N_SELF_CUST_PRIVILEGE_ID=10}, {N_SELF_CUST_PRIVILEGE_ID=1}, {N_SELF_CUST_PRIVILEGE_ID=2}, {N_SELF_CUST_PRIVILEGE_ID=3}, {N_SELF_CUST_PRIVILEGE_ID=4}, {N_SELF_CUST_PRIVILEGE_ID=5}, {N_SELF_CUST_PRIVILEGE_ID=6}]
 小弟刚入行,很多都不会,现在我想要获取出数字,然后放到数组里,传到前台jsp页面去。应该怎样写,数字不是N_SELF_CUST_PRIVILEGE_ID=1的,就要1,补充下,我用的是struts1

解决方案 »

  1.   

    List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
    int x=1;
    for (FundShopDao fundShopDao : fundShopDaos) {
    HashMap<String, Object> item = new HashMap<String, Object>();
    item.put("xuhao", x++);
    item.put("code", fundShopDao.getCode());
    item.put("investobj", fundShopDao.getInvestObj());
    item.put("opendate", fundShopDao.getOpendate());
    item.put("scale", fundShopDao.getScale());
    item.put("shortname", fundShopDao.getShortname());
    item.put("type", fundShopDao.getType());
    item.put("fundmangt", fundShopDao.getFundmangt());
    data.add(item);
    }类似于这样转换吧
      

  2.   

    List<Map<String,Object>> list = ...
    String ids[] = new String[list.size()];

    for(int i = 0; i < list.size(); i++) {

    Map<String, Object> map = (Map<String, Object>)list.get(i);

    ids[i] = map.get("N_SELF_CUST_PRIVILEGE_ID").toString();
    }