czj11600
czj11600
2010-12-06 16:29
浏览 920
已采纳

groovy中map取值问题

我输出map得到的是
[enterprisecode:xx, usercode:xx, username:xx, password:xx, defaultgroupid:xx, phonenumber:null, languagecode:CN, erpenterprisecode:null, erpusercode:null, year:2010, month:201012, today:2010/12/06]
但我用map.get("languagecode") 和 map.usercode得到的都是null,请问是什么情况

我自己定义的map类型[usercode:'xx']都能用map.usercode显示出来,这个是不明白

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • beneo
    beneo 2010-12-07 09:26
    已采纳

    groovy我也是才起步
    [code="java"]
    for(i in 0..map.size()-1){
    var.put( ""+"${map.get(i)}","${""+rs.getString("${map.get(i)}")}")
    }
    [/code]

    这样你试试

    点赞 评论
  • beneo
    beneo 2010-12-06 17:09

    [code="java"]
    map = [enterprisecode:xx, usercode:xx, username:xx, password:xx, defaultgroupid:xx, phonenumber:null, languagecode:CN, erpenterprisecode:null, erpusercode:null, year:2010, month:201012, today:2010/12/06]

    [/code]

    给enterprisecode加上""

    点赞 评论
  • beneo
    beneo 2010-12-06 17:58

    [code="java"]
    scores = ["Brett": 100, "Pete": "Did not finish", "Andrew": 86.87934]
    scores.put("${scores.get("Brett")}", "100")
    println scores["Pete"]
    println scores.get("Brett")
    println scores

    scores.each {
    key, value ->
    println "kye " + key.getClass() + " value " + value.getClass()

    }
    [/code]


    [code="java"]
    scores = ["Brett": 100, "Pete": "Did not finish", "Andrew": 86.87934]
    scores.put("" + "${scores.get("Brett")}", "100")
    println scores["Pete"]
    println scores.get("Brett")
    println scores

    scores.each {
    key, value ->
    println "kye " + key.getClass() + " value " + value.getClass()

    }
    [/code]

    点赞 评论
  • beneo
    beneo 2010-12-07 09:27

    [quote]
    for(i in 0..map.size()-1){
    var.put( ""+"${map.get(i)}",""+rs.getString(""+"${map.get(i)}"))
    }

    [/quote]

    点赞 评论

相关推荐