在jstl中使用变量值作为参数调用另一个变量
逻辑是这样的:
<c:set var="vehicle" value="car">
<c:set var="car" value="ferrari">
由于 ${vehicle} = "car"
的值也是具有“ferrari”值的变量的名称,因此我使用 $ 间接访问它{'${vehicle}'}
但它似乎不起作用。有人可以帮我解决这个问题吗?谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这种事情在 java 中通常不起作用(没有
eval
语句)。然而,在这种情况下,变量绑定到请求上下文,所以我想您可以像这样访问它(假设变量已分配给请求范围):但我无法验证这一点,因为我还没有编写任何 JSP代码大约3年。
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):But I can't verify that, because I have not written any JSP code for about 3 years.
我不认为这是受支持的,如果它是
${'${vehicle}'}
就不是它的逻辑语法。 (假设它更像是${${vehicle}}
...)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.)