如何将特殊字符传递给ManagedBean

时间:2016-07-15 19:58:43

标签: jsf encoding primefaces el

阅读以下问题(How set charset in a primefaces webapp?),我试图将一些特殊字符作为参数传递给managedBean(例如:''''''''''''''''''''''''''''''问题的答案不起作用:

JBWEB000065: HTTP Status 500 - /utf8/utf8_test.xhtml @23,153 value="#{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}" EL Expression Unbalanced: ... #{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}


JBWEB000309: type JBWEB000066: Exception report

JBWEB000068: message /utf8/utf8_test.xhtml @23,153 value="#{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}" EL Expression Unbalanced: ... #{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}

JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.

JBWEB000070: exception 
javax.servlet.ServletException: /utf8/utf8_test.xhtml @23,153 value="#{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}" EL Expression Unbalanced: ... #{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
    cl.gov.minterior.ncforms.managedbeans.UtfFilter.doFilter(UtfFilter.java:39)



JBWEB000071: root cause 
javax.faces.view.facelets.TagAttributeException: /utf8/utf8_test.xhtml @23,153 value="#{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}" EL Expression Unbalanced: ... #{testBean.testEncoding(''´áéíóúÁÉÍÓÚ&')}
    com.sun.faces.facelets.tag.TagAttributeImpl.<init>(TagAttributeImpl.java:115)
    com.sun.faces.facelets.compiler.SAXCompiler$CompilationHandler.createAttributes(SAXCompiler.java:133)
    com.sun.faces.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:259)
    org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:496)
    org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:180)
    org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:810)
    org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:275)
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1653)
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
    org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
    org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
    org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
    org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1196)
    org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:555)
    org.apache.xerces.jaxp.SAXParserImpl.parse(SAXParserImpl.java:289)
    javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
    com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:427)
    com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:403)
    com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:124)
    com.sun.faces.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:319)
    com.sun.faces.facelets.impl.DefaultFaceletFactory.access$100(DefaultFaceletFactory.java:92)
    com.sun.faces.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:159)
    com.sun.faces.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:157)
    com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:79)
    com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:74)
    com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99)
    java.util.concurrent.FutureTask.run(FutureTask.java:266)
    com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114)
    com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:117)
    com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:58)
    com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:256)
    com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:200)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:908)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

到目前为止,问题似乎是“'”(')字符,因为某些方法在将其发送到托管bean之前会对其进行转换,

调用托管bean的代码是:

<h:outputText value="#{testBean.pruebaEncoding('&#39;&#180;&#225;&#233;&#237;&#243;&#250;&#193;&#201;&#205;&#211;&#218;&amp;')}" />

和托管bean:

public String pruebaEncoding(String strencoded) {

    FileWriter writer;
    try {
        writer = new FileWriter("/desarrollo/workspaces/workspace-eclipse-mars-test/project/filter.test");

        writer.write(strencoded);

        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return strencoded;
}

感谢您的帮助

提示:重要的是应用程序可以将结果写入文件,因为另一个ant脚本使用它来做一些事情()

0 个答案:

没有答案