about SAXparseException: content is not allowed in prolog

后端 未结 1 1858
Happy的楠姐
Happy的楠姐 2021-01-15 11:42

I am using glassfish server and the following error keeps coming:

Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at com.         


        
1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 12:18

    Check this link

    http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html

    In short, some XML file contains the three-byte pattern (0xEF 0xBB 0xBF) at the front (right before ), which is the UTF-8 byte order mark. The java's default XML parser can't handle this case.

    The quick and dirty solution is to remove the white space at the front of the XML file:

    String xml = "

    note that the String.trim() dost not enough, since it only trim the limited whitespace characters.

    0 讨论(0)
提交回复
热议问题