开发者

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

开发者 https://www.devze.com 2023-03-28 05:52 出处:网络
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.

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

精彩评论

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