EL get value of a HashMap by Integer key

前端 未结 2 489
感情败类
感情败类 2020-12-18 08:11

I have this HashMap:

    Map odometerMap = new LinkedHashMap();
    odometerMap.put(0, getLocaleForKey(\"drop-d         


        
2条回答
  •  情话喂你
    2020-12-18 08:27

    In EL, numbers are treated as Long. It's looking for a Long key. It'll work if you use Long instead of Integer as map key.

    Map odometerMap = new LinkedHashMap();
    odometerMap.put(0L, getLocaleForKey("drop-down.any"));
    odometerMap.put(1L, "< 1000");
    // ...
    

提交回复
热议问题