使用变量值作为jstl中的参数调用另一个变量 [英] calling another variable using a variable value as parameter in jstl

查看:158
本文介绍了使用变量值作为jstl中的参数调用另一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

逻辑在某种程度上是这样的:

the logic is somehow like this:

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

因为 $ {vehicle} =car的价值这也是变量的名称,其值为ferrari我使用 $ {'$ {vehicle}'} 间接访问它但它没有'似乎工作。有人可以帮我弄这个吗。谢谢

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

推荐答案

这种东西通常不适用于java(没有 eval 声明)。但是,在这种情况下,变量绑定到请求上下文,所以我猜你可以像这样访问它(假设变量被分配给请求范围):

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]}

但我不能验证,因为我还没有编写任何JSP代码大约3年。

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

这篇关于使用变量值作为jstl中的参数调用另一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆