Detailed explanation of the case of JSTL reading Chinese garbled XML and solving the problem

黄舟
Release: 2017-03-30 14:18:41
Original
1652 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!