Results 1 to 3 of 3

Thread: Jstl c:set question

  1. #1
    Join Date
    Oct 2008
    Posts
    16

    Default Jstl c:set question

    I am using spring bind tags for the first time and I am setting a variable with jstl within the bind tags as follows:

    <spring:bind path="*******" >
    <c:set var="editable" value="c:out value='${status.value}' />" />
    </spring:bind>

    When I display the var editable as below, I see either the values true or false, which is what I expected.

    <c:out value="${editable}" />

    However, if I do an if test immediately following the display above on the editable var checking for true or false, neither condition is ever met.

    <c:if test="${editable == 'true'}>
    some output
    </c:if

    <c:if test="${editable == 'false'}>
    some other output
    </c:if

    Why is the if test failing? Do I have a syntax error?

    Thank you.

  2. #2
    Join Date
    Oct 2008
    Posts
    16

    Default

    I see my problem, the value being displayed is not true or false, but
    <c:out value='false'.

    I will have to look at how to fix this.

    Thank you

  3. #3
    Join Date
    Oct 2008
    Posts
    6

    Default

    If editable is a boolean, you can also do:
    Code:
    <c:if test="${editable == true}>
    some output
    </c:if>
    Maybe JSTL checks it as a String.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •