I'm writing this:
<c:forEach var="cntr" begin="1" end="10">
<c:set var="mycase" value="${param.mode${cntr}}" />
<c:if test="${mycase != null}">
<c:param name="mode${cntr}" value="${mycase}"/>
</c:if>
</c:forEach>
The result I want is for the redirect that sits outside of this to inherit the values of param.mode1
, param.mode2
, etc. as if I wrote:
<c:if test="${param.mode1 != null}">
<c:param name="mode1" value="${param.mode1}"/>
</c:if>
<c:if test="${param.mode2 != null}">
<c:param name="mode2" value="${param.mode2}"/>
</c:if>
<c:if test="${param.mode3 != null}">
<c:param name="mode3" value="${param.mode1}"/>
</c:if>
<c:开发者_JS百科if test="${param.mode4 != null}">
<c:param name="mode4" value="${param.mode2}"/>
</c:if>
<c:if test="${param.mode5 != null}">
<c:param name="mode5" value="${param.mode1}"/>
</c:if>
<c:if test="${param.mode6 != null}">
<c:param name="mode6" value="${param.mode2}"/>
</c:if>
All help appreciated.
You've to set another variable with mode${cntr}
and to get the associated value using brace notation wherein you can pass a dynamic key.
<c:forEach var="cntr" begin="1" end="10">
<c:set var="mode" value="mode${cntr}" />
<c:set var="mycase" value="${param[mode]}" />
<c:if test="${mycase != null}">
<c:param name="mode${cntr}" value="${mycase}"/>
</c:if>
</c:forEach>
精彩评论