Home >Backend Development >XML/RSS Tutorial >Detailed explanation of the case of JSTL reading Chinese garbled XML and solving the problem
Use the xml tag of JSTL to analyze and display the xml file and encounter the Chinese Garbled code problem. The xml file uses utf-8, jsp uses utf-8, htmlcharacter set is set to utf-8, it should be No garbled characters.
After careful analysis, the problem occurs in the c:import statement. If you specify the correct character set for the statement, there will be no garbled characters.
<x:parse var="parsedDoc"> <c:import url="test.cxml" charEncoding="utf-8"></c:import> </x:parse> <h1>读取内容:</h1> <x:out select="$parsedDoc/Collection/Items/Item[@Id=0]/Description"/><br>
Test The content of .cxml is as follows:
<?xml version="1.0" encoding="utf-8"?> <Collection> <Items> <Item Id="0"> <Description>隔壁老王的博客,wallimn</Description> </Item> <Item Id="1"> <Description>http://wallimn.iteye.com</Description> </Item> <Item Id="3"> <Description>这是一段中文信息。</Description> </Item> </Items> </Collection>
The above is the detailed content of Detailed explanation of the case of JSTL reading Chinese garbled XML and solving the problem. For more information, please follow other related articles on the PHP Chinese website!