0

I'm creating multidimensional arrays with JSTL which should be:

[ ['2013-03',22434.0],['2013-04',11234.0],['2013-05',17434.0] ]

And while doing this with JSTL, I white code like this:

var arrayz = new Array(${list.size()});
<c:forEach var="item" items="${list}" varStatus="s">
  arrayz[${s.index}] = new Array(["'" + "${item.date}".substring(0,7) + "'", ${item.price}]);
</c:forEach>
console.log("arrayz: " + arrayz);

In the console it turns out to be :

arrayz: '2013-03',22434.3,'2013-04',11234.1,'2013-05',17425

How to fix it?

1 Answer 1

1

Your array is fine your just seeing the output as a string, try just logging the array by itself

console.log(arrayz);

also might I suggest some simplification of your jstl.

var arrayz = [
<c:forEach var="item" items="${list}" varStatus="s">
    ["'" + "${item.date}".substring(0,7) + "'", ${item.price}]${!s.last?',':''}
</c:forEach>
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.