im using "pre" tags in order to allow a textarea box to pass over newlines because Im stripping html out the form when its subitted. The problem is with adding the "pre"...my table cell expands to enournous proportions and I dont know why.....
Thanks in advance
Before pre tag:
after pre tag:
Heres the code for that table:
<form id="commentForm" name="commentForm" action="" method="post">
<ctl:vertScroll height="300" headerStyleClass="data_table_scroll" bodyStyleClass="data_table_scroll" enabled="${user.scrollTables}">
<ctl:sortableTblHdrSetup topTotal="false" href="show.whatif_edit_entry?entryId=${entry.entryId}"/>
<table class="data_table vert_scroll_table" style="width:360px;">
<tr>
<ctl:sortableTblHdr styleClass="center" title="Comments" property="comment" type="top">Comments</ctl:sortableTblHdr>
<ctl:sortableTblHdr styleClass="center" title="Created By" property="auditable.createdBy.lastName" type="top">Entered By</ctl:sortableTblHdr>
</tr>
<c:forEach var="comments" items="${entry.comments}">
//PRE HERE!! ----->>> <tr id="id${comments.id}">
<td id="comments-${comments.id}" style="width:360px;"><pre>${comments.comment}</pre></td>
<c:choose>
<c:when test="${comments.auditable != null}">
<td title="${comments.auditable.createdBy.lastName}, ${comments.auditable.createdBy.firstName} on
<fmt:formatDate value="${comments.auditable.createdDate}" pattern="${date_time_pattern}" />"><span class="mouseover_text">${comments.auditable.createdBy.lastName}, ${comments.auditable.createdBy.firstName} on
<fmt:formatDate value="${comments.auditable.createdDate}" pattern="${date_time_pattern}" />
</td>
</c:when>
<c:otherwise>
<td colspan="1"> </td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
<c:if test="${lock.locked || form.entryId < 0 }">
<%-- This is the row for adding a new comment. --%>
<tr id="commentRow">
<td>
You have <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH'] - fn:length(commentForm.comment)}</span></strong> characters left.<br/>
<textarea id="comment" name="comment" rows="2" cols="125" style="width:320px;"
onkeypress="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
onkeydown="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
onkeyup="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"></textarea>
开发者_运维百科 <a href="javascript:addComment();"><img src="../images/icon_add.gif" border="0" alt="Add"/></a>
</td>
<td class="shaded" colspan="1"> </td>
</tr>
</c:if>
</table>
pre
{
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
width: 99%;
}
Your problem is: width: 99%;
in pre
. Remove that line.
Don't (ab)use <pre>
. Just use <c:out>
to HTML-escape user-controlled input to prevent XSS.
<c:out value="${comments.comment}" />
精彩评论