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> 

front end view

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 -

enter image description here

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">&lt;/table&gt;</td> 

if change previous example use function, want:

enter image description here


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -