0

With JSTL I have to build an array (in string format) and then pass it to a Javascript function.

My gol is to have a string like this: "abc","ghjh","fsd"

I started doing something like this:

<c:forEach items="${items}" var="item">
       <c:set var="array">${array}"${item.value}"</c:set>       
</c:forEach>

<script>
var sliderLinks = [<c:out value="${array}"/>];
</script>

But when I see the source code of the instead of " I have &#034;

I tried this solution but I keep on getting the same problem.

Thank you in advance

Community
  • 1
  • 1
MDP
  • 4,177
  • 21
  • 63
  • 119

1 Answers1

2

You can push the items into the array one by one:

<script>
    var sliderLinks = new Array();
    <c:forEach items="${items}" var="item">
        sliderLinks.push(${item.value});
    </c:forEach>
</script>
johnnyaug
  • 887
  • 8
  • 24