Good day.
There is such a task: in JSP, with the help of JSTL
( <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
) implement the output of information in JSON format. And nothing else. The task is simple, not requiring much effort. But here I braked on a simple task. It is necessary to implement the output in the map array Map<String, String>
. I did it like this:
[ <c:forEach var="item" items="${payParam.format}"> "<c:out value="${payParam.description}"/>":"<c:out value="${item.value}" />", </c:forEach> ]
The problem is that at the end of the line, after each cycle, there is always a comma. Tell me, please, how can I check if a comma is needed? Those. If the element in the card is the last, then a comma is not needed.