我正在尝试在此标记中调用JS函数escapeHtml(unsafe)
file.jsp
<form:form modelAttribute="messagingForm" id="messagingForm" action="${messagingSendUrl}">
[...]
<foo:bar string="${escapeHtml(messagingForm.text)}" substring="${searchstring}"/>
[...]
</form:form>
<script type="text/javascript">
function escapeHtml(unsafe) {
[...]
}
</script>
我收到此错误:当未指定默认命名空间时,函数escapeHtml必须与前缀一起使用。
我试过了:
<foo:bar string="<spring:message code="escapeHtml('${messagingForm.text}')"/>" substring="${searchstring}"/>
我收到此错误:file.jsp(xx,17)等于符号预期
和:java.lang.ClassNotFoundException
我试过了:
<foo:bar string="<spring:message code='escapeHtml("${messagingForm.text}")'/>" substring="${searchstring}"/>
我收到此错误:file.jsp(xx,xx)Unterminated&amp; lt; foo:bar tag
====为Anthony Grist编辑====
好吧,我可以这样做:
<c:when test="${reply}">
<button id="btn_msg_reply_dispatcher"
title="<spring:message
code="messaging.alt.replyvehicleanddispatcher"
argumentSeparator=";"
arguments="${vehicleName};${sender}" />"
onclick="replyVehicleAndDispatcher(${vehicleInformationId}, ${sid}, '${sender}'); return false;">
</button>
</c:when>
[...]
<script type="text/javascript">
function replyVehicleAndDispatcher(vehicleInformationId, userId, userName) {
[...]
}
</script>
答案 0 :(得分:0)
<c:set var="msg"><spring:message code="${messagingForm.text}" htmlEscape="true"/></c:set>
<foo:bar substring="${searchstring}" string="${msg}" />