My JSP file contains a table with the following row:
<td class="description" id="${doc.id}"></td>
I want it to be empty at first, as above. Later, after the page is loaded and some logic is processed, I want to fill it asynchronously with a content using JQuery .html
method:
$("#${doc.id}").html("${doc.description}");
For regular user inputs everything works fine, but error occurs, when a user enters special character: "
How can I prevent application from reading that character as special, and have the application running correctly?
I have tried to use JSP escape functions like this:
$("#${doc.id}").html("${fn:escapeXml(doc.description)}");
And this:
$("#${doc.id}").html("<c:out value="${doc.description}"/>");
And neither first nor second worked. Why?
Here is one way - seeing you already have the data on the page
<td class="description hide" id="${doc.id}"><c:out value="${doc.description}"/></td>
where
.hide is {display:none}
and then
$("#${doc.id}").show();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.