错误堆栈跟踪:

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)

最佳答案

观察值:

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

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

    示例gsp代码:
    var abc = "S & P 500";
    <p>abc.encodeAsHTML()</p>
    

    关于grails - 将我的gsp页面转换为pdf时出现错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15998656/

    10-14 12:55