我正在尝试创建一个表,当“key”等于“name”时,该值是指向另一个页面的链接,否则它应该将值打印为text.I有以下键:[name ,类别,架构]。这是一个ArrayList
<c:when test='#{(results.keys.get(loopVal.index)).equals("name")}'>
在我的表中,“name”列应该将值作为链接。但它不起作用,就好像c:when返回false。但我检查了“results.keys.get(loopVal.index)”并正确打印了密钥。
我尝试用equals(),==和eq进行比较。我也有正确的jstl库xmlns:c =“http://java.sun.com/jsp/jstl/core”
我找不到问题,也许它与比较列表元素有关?还是我忽略了一些非常明显的东西?
以下是我的代码的更大片段:
<ui:repeat value="#{results.keys}" var="key" varStatus="loopVal">
<td id="#{results.keys.get(loopVal.index)}_#{instance.getId()}" class="view">
<c:choose>
<c:when test='#{(results.keys.get(loopVal.index)).equals("name")}'>
<h:link value="#{values.get(loopVal.index)}" outcome="search">
<f:param name="type" value="#{values.get(loopVal.index)}" />
</h:link>
</c:when>
<c:otherwise>
#{values.get(loopVal.index)}
</c:otherwise>
</c:choose>
</td>
</ui:repeat>
答案 0 :(得分:1)
您应该使用c:forEach
代替ui:repeat
:
<c:forEach items="#{results.keys}" var="key" varStatus="loopVal">
...
</c:forEach>
请参阅BalusC的this post,了解标记处理程序(如c:forEach
)与普通JSF组件(如ui:repeat
)之间的区别。