开发者

How to use a variable data as a scope variable in jstl

I want to dynamically create variable names in java el. The problem is that the second line returns sessionScope.saved_activity as a string instead of data.

<c:set var="savedKey" value="sessionScope.saved_${entry.key}" />

<td> <input type="text" name="${entry.key}" value="${savedKey}"> </td>

How can I retrieve the data from 开发者_开发问答a string in el ?


You need to create the sole key name and then use that as a dynamic key of the ${sessionScope} with the brace notation.

<c:set var="savedKeyName" value="saved_${entry.key}" />
<input type="text" name="${entry.key}" value="${sessionScope[savedKeyName]}">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜