Announcement Announcement Module
Collapse
No announcement yet.
JSTL and string concatenation possible? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSTL and string concatenation possible?

    I have ${stub} = 2@3# and ${levels} = [1, 2, 3, 4]

    I would like to do something like
    Code:
    <c&#58;forEach var="level" items="$&#123;levels&#125;">
      <c&#58;out value="$&#123;stub&#125;$&#123;level&#125;"/>
    </c&#58;forEach>
    resulting in
    • 2@3#1
      2@3#2
      2@3#3
      2@3#4

    I've tried every(?) possible combination. Is String concat without any blankspace possible in JSTL?

  • #2
    did you try
    Code:
    <c&#58;forEach var="level" items="$&#123;levels&#125;"> 
      <c&#58;out value="$&#123;stub&#125;"/><c&#58;out value="$&#123;level&#125;"/> 
    </c&#58;forEach>

    Comment


    • #3
      Hi

      Problem is I have to assign it to a new variable:

      Code:
      <c&#58;set var="stubplus" value="<c&#58;out value="$&#123;stub&#125;"/><c&#58;out value="$&#123;level&#125;"/>" />
      Chokes on "unterminated tag" unforunately....

      Comment


      • #4
        Then try this
        Code:
        <c&#58;forEach var="level" items="$&#123;levels&#125;"> 
          <c&#58;set var="stubplus" value="$&#123;stub&#125;$&#123;level&#125;" /> 
          <c&#58;out value="$&#123;stubplus&#125;"/>
        </c&#58;forEach>

        Comment


        • #5
          Mark Kolb wrote a good article about JSTL on developerWorks.

          Comment


          • #6
            Thanks! Appreciate your answers.

            Comment

            Working...
            X