1

错误堆栈跟踪:

org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:638)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:189)
    at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:75)
    at org.xhtmlrenderer.resource.XMLResource$load.call(Unknown Source)
    at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:55)
    at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:43)
    at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:38)
    at grails.plugin.rendering.document.XhtmlDocumentService$createDocument.call(Unknown Source)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:34)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:33)
    at grails.plugin.rendering.RenderingService$render$0.callCurrent(Unknown Source)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:63)
    at grails.plugin.rendering.RenderingService$render.call(Unknown Source)
    at RenderingGrailsPlugin$_closure1.doCall(RenderingGrailsPlugin.groovy:48)
    at RenderingGrailsPlugin$_closure1.call(RenderingGrailsPlugin.groovy)
    at com.zocampus.ExamScoresController$_closure31.doCall(ExamScoresController.groovy:525)
    at com.zocampus.ExamScoresController$_closure31.doCall(ExamScoresController.groovy)
    at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
    at java.lang.Thread.run(Thread.java:619)
4

1 回答 1

2

观察:

  • 您正在使用 Grails 渲染插件。
  • 您在 gsp 中有一个元素,其文本中有一个“&”。例如:标签为<p>S & P 500</p>

解决方案: 字符串需要编码为 HTML。在您期望 '&' 的 gsp 中使用.encodeAsHTML()

示例 gsp 代码:

var abc = "S & P 500";
<p>abc.encodeAsHTML()</p>
于 2013-04-14T13:15:10.743 回答