Combining a string with the value of a variable to be the name of another variable in EL

后端 未结 4 1260
Happy的楠姐
Happy的楠姐 2021-02-19 07:12

I want to do something like this:


But it does not work throws exception: \"${summary${selChrm

4条回答
  •  时光取名叫无心
    2021-02-19 07:52

    You cannot nest EL expressions. You can however just concatenate them.

    
    

    Or, if ${summary} is actually not an object in any of the scopes, do

    
    

    Update: OK, you actually need to access ${summary01}. If you know the scope beforehand, then you can access it using the brace notation. Imagine that it's request scoped, you could access it "plain" as follows:

    
    

    But you can actually also use another EL variable in the braces (just unquote it):

    
    

    So, we'd like to set it somewhere. The JSTL c:set tag is perfectly suitable for this:

    
    

提交回复
热议问题