Access map value in EL using a variable as key

前端 未结 5 949
野性不改
野性不改 2020-12-14 03:08

I have a Map in EL as ${map} and I am trying to get the value of it using a key which is by itself also an EL variable ${key} with the

5条回答
  •  有刺的猬
    2020-12-14 03:38

    $ is not the start of a variable name, it indicates the start of an expression. You should use ${map[key]} to access the property key in map map.

    You can try it on a page with a GET parameter, using the following query string for example ?whatEver=something

    
    whatEver: 
    

    This will output:

    whatEver: something
    

    See: https://stackoverflow.com/tags/el/info and scroll to the section "Brace notation".

提交回复
热议问题