使用JSTL的xml标签,分析显示xml文件,遇到中文http://www.php.cn/code/5829.html" target="_blank">乱码问题。xml文件使用utf-8、jsp使用utf-8、html字符集设置为utf-8,按说应该不出现乱码。 仔细分析,问
仔细分析,问题出现在c:import语句,为该语句指定正确的字符集,就不会出现乱码了。
Html代码
<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.cxml的内容如下:
<?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>以上就是详解JSTL读取xml中文乱码解决的案例的详细内容,更多请关注自由互联其它相关文章!
