calling another variable using a variable value as parameter in jstl

耗尽温柔 提交于 2019-12-21 23:10:34

问题


the logic is somehow like this:

<c:set var="vehicle" value="car">
<c:set var="car" value="ferrari">

since the value of ${vehicle} = "car" which is also the name of the variable with the value of "ferrari" i access it indirectly using ${'${vehicle}'} but it doesn't seem to work. Can someone help me with this. thanks


回答1:


This kind of things doesn't usually work in java (there's no eval statement). In this case however, the variables are bound to the request context, so I guess you could access it something like this (assuming the variables were assigned to request scope):

${requestScope[vehicle]}

But I can't verify that, because I have not written any JSP code for about 3 years.




回答2:


I don't think this is supported, and if it was ${'${vehicle}'} wouldn't be the logical syntax for it. (It would be more like ${${vehicle}} ... hypothetically.)



来源:https://stackoverflow.com/questions/4132865/calling-another-variable-using-a-variable-value-as-parameter-in-jstl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!