Conditional check in c: if always fails

The c: if test always fails for me, and it never gets inside the loop. I use the following namespaces

xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:c="http://java.sun.com/jstl/core"

The string ('array') to be broken is "Tom and Jerry are friends of GAP1"

<s:decorate template="/layout/display-text.xhtml">
    <c:set var="array" value="#{_mybean.value}"/>
    <c:set var="space" value="#{fn:split(array, ' ')}"/>
    <c:set var="len" value="#{fn:length(space)}"/>
    <h:outputText value="total length = #{len}"/><br/>
    <c:forEach begin="0" end="5" var="index">
        <h:outputText value="index = #{index}, value = #{space[index]}"/><br/>
        <c:set var="val" value="#{space[index]}"/>
        <c:if test="#{fn:startsWith(val, 'GAP')}">
            <h:outputText value="Found keyword parameter GAP" /><br/>
        </c:if>
    </c:forEach>
</s:decorate>
+3
source share
1 answer

The JSTL kernel ID is invalid. According to the JSTL TLD, this should be (note the extra /jsp):

xmlns:c="http://java.sun.com/jsp/jstl/core"

, JSF JSTL . , , , . , JSP/JSTL , JSF . . / JSF.

c:forEach Seam a4j:repeat Facelets 'ui:repeat, c:if rendered JSF, , /. JSTL c:set, bean getter.

JSTL (fn) taglib, , - JSF. .

+7

Source: https://habr.com/ru/post/1729064/


All Articles