jsp - setting id for tr(table row ) not working -
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>
view source code above screen shot
what issue not generating tr id
use single quotes instead of double. work:
<tbody> <c:foreach items="${notelist}" var="note" varstatus="count"> <tr id="<c:out value='${count.count}'/>"> ... </tr> </c:foreach> </tbody>
updated. 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 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 may in fields of objects. example, notetext
field may contain special characters. example, closing tag - </table>
.
<c:set var="str" value="</table>"/>
then -
the fn:escapexml()
function escapes characters interpreted xml markup. result in following case -
<td id="notecontent${count.count}">${fn:escapexml(str)}</td>
you'll -
<td id="notecontent3"></table></td>
if change previous example use function, want:
Comments
Post a Comment