错误堆栈跟踪:
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)
答案 0 :(得分:2)
<强>观察:强>
<p>S & P 500</p>
<强>解决方案:强>
该字符串需要编码为HTML。在gsp中使用.encodeAsHTML()
您期望的'&amp;'。
示例gsp代码:
var abc = "S & P 500";
<p>abc.encodeAsHTML()</p>