When I use the jstl tag to read theXMLfile, I always get the error "Content is not allowed in the preface". After checking, the XML file format and content are correct. After searching on Baidu, I found out that it was a file encoding problem.
Use Notepad to open the xml file and convert it to UTF-8. There will be a BOM header, so java will report the above error when reading.
Solution: Open it with notepad++, select "Encode in UTF-8 BOM-free format" in the format, and then save it. You can also use EmEditor to save as a file, and select "UTF-8 No Signature" when saving.
The above is the detailed content of Detailed explanation of how to handle the 'Content is not allowed in the preface' error when reading an XML file. For more information, please follow other related articles on the PHP Chinese website!