0

Jsp Code:

<tbody>
                    <c:forEach items="${noteList}" var="note" varStatus="count">
                        <tr id="<c:out value="${count.count}"/>">
                            <td id="noteType${count.count}">
                                Transaction Note
                            </td>
                            <td id="noteEnteredDate${count.count}">${note.formattedEnteredOn}</td>
                            <td id="noteEnteredBy${count.count}">${note.formattedUserInitials}</td>
                            <td id="noteContent${count.count}">${note.noteText}</td>
                        </tr> 
                    </c:forEach> 
                </tbody>

front end view

view source code for above screen shot

what would be the issue for not generating tr id

1 Answers1

0

Use single quotes instead of double. This will work:

<tbody>
    <c:forEach items="${noteList}" var="note" varStatus="count">
        <tr id="<c:out value='${count.count}'/>">
           ...
        </tr> 
    </c:forEach> 
</tbody>

Updated. This JSTL code -

<table>
<thead></thead>
<tbody>
<c:forEach items="${noteList}" var="note" varStatus="count">
    <tr id="<c:out value='${count.count}'/>">
        <td id="noteType${count.count}">
            Transaction Note
        </td>
        <td id="noteEnteredDate${count.count}">1</td>
        <td id="noteEnteredBy${count.count}">2</td>
        <td id="noteContent${count.count}">3</td>
    </tr>
</c:forEach>
</tbody>
</table>

Generates the following HTML markup -

<table>
<thead></thead>
<tbody>

    <tr id="1">
        <td id="noteType1">
            Transaction Note
        </td>
        <td id="noteEnteredDate1">1</td>
        <td id="noteEnteredBy1">2</td>
        <td id="noteContent1">3</td>
    </tr>

    etc...

</tbody>

The issue also may be in the fields of the objects. For example, noteText field may contain special characters. For example, the closing tag - </table>.

<c:set var="str" value="</table>"/>

Then we get something like this -

enter image description here

The fn:escapeXml() function escapes characters that could be interpreted as XML markup. As a result in the following case -

<td id="noteContent${count.count}">${fn:escapeXml(str)}</td> 

You'll get -

<td id="noteContent3">&lt;/table&gt;</td>

If you change the previous example to use this function, you will get what you want:

enter image description here