我是jsp和jSTL技术的新手。我正在尝试打印 <c:out value>
中的一些文本,请参见代码中的第1点。我正在尝试显示这样的文本 -
Account Manager-5
这里${aStageRole.displayName} = 'Account Manager'
( pro.stageRoles
) 是一个长度为 5
的数组.
<select id="selectRole<%=i %>" onchange="javascript:selectRole('selectRole<%=i %>')">
<c:forEach items="${pro.stageRoles}" var="aStageRole" varStatus="status">
<option value="${aStageRole.role.id}"> <c:out value="${aStageRole.displayName}-{fn:length(pro.stageRoles)}"/></option> //1
</c:forEach>
</select>
但是代码在下拉列表中输出以下值 -
Account Manager-{fn:length(pro.stageRoles)}
谁能帮我解决这个问题吗?
最佳答案
JSTL 中的表达式由 ${}
括起来。代码 {fn:length(pro.stageRoles)}
部分不会被评估为没有 $ 符号的 JSP EL。
${fn:length(pro.stageRoles)}
关于java - 在 JSTL 中使用 'fn' 打印数组长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27592365/