我终于用以下代码解决了这个问题:
<c:set var="myContent" value="${row.content}"/>
<c:set var="singlequote" value="'"/>
<c:set var="backslash" value="\\"/>
<c:if test="${fn:contains(myContent, singlequote) && !fn:contains(myContent,backslash)}">
<c:set var="search" value="'" />
<c:set var="replace" value="\\'" />
<c:set var="myContent" value="${fn:replace(myContent, search, replace)}"/>
</c:if>
<c:if test="${fn:contains(myContent, backslash) && !fn:contains(myContent,singlequote)}">
<c:set var="search" value="\\" />
<c:set var="replace" value="\\\\" />
<c:set var="myContent" value="${fn:replace(myContent, search, replace)}"/>
</c:if>
<c:if test="${fn:contains(myContent, singlequote) && fn:contains(myContent,backslash)}">
<c:set var="search" value="\\"/>
<c:set var="replace" value="\\\\" />
<c:set var="myContent" value="${fn:replace(myContent, search, replace)}"/>
<c:set var="find" value="'"/>
<c:set var="change" value="\\'" />
<c:set var="myContent" value="${fn:replace(myContent, find, change)}"/>
</c:if>
<script language="JavaScript" type="text/JavaScript">
window.addEventListener("load", function(){
element.innerHTML='${myContent}';
}, true);
</script>