How to stop html textarea from interpreting html entities into their characters

落花浮王杯 提交于 2019-11-29 18:06:56

So you want to escape HTML entities? You can use either JSTL <c:out> or fn:escapeXml().

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<textarea><c:out value="${bean.text}" /></textarea>

or

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<textarea>${fn:escapeXml(bean.text)}</textarea>

It will by default escape under each & to &amp; so that for example &reg; ends up to become &amp;reg; and this way it will be displayed as &reg;.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!