婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > 包含中文字符的URL編碼問(wèn)題

包含中文字符的URL編碼問(wèn)題

熱門(mén)標(biāo)簽:高德地圖地圖標(biāo)注服務(wù)中心 東營(yíng)電銷(xiāo) 隨州外呼調(diào)研系統(tǒng) 微信地圖標(biāo)注合并了 南寧網(wǎng)絡(luò)外呼系統(tǒng)運(yùn)營(yíng)商 本地電話機(jī)器人 r語(yǔ)言數(shù)據(jù)可視化地圖標(biāo)注 如何修改多個(gè)百度地圖標(biāo)注 400電話辦理包年

在xml應(yīng)用中,經(jīng)常將一些URL信息作為xml數(shù)據(jù)存儲(chǔ),其中URL參數(shù)有可能包含有中文字符。當(dāng)使用dom對(duì)xml數(shù)據(jù)進(jìn)行解析時(shí),可以對(duì)中文字符進(jìn)行編碼。
但如果只使用xslt來(lái)顯示xml數(shù)據(jù)時(shí)(data.xml+data.xsl),發(fā)現(xiàn)此時(shí)的URL會(huì)出現(xiàn)編碼錯(cuò)誤.即使指定編碼類(lèi)型(encoding="gb2312"),依然會(huì)出現(xiàn)同樣的問(wèn)題.
測(cè)試發(fā)現(xiàn):是IE的緩存機(jī)制問(wèn)題,IE仍會(huì)把新的頁(yè)面(所鏈接的URL)的MIME內(nèi)容類(lèi)型默認(rèn)為text/xml

解決方法:
1.指定輸出文檔類(lèi)型為xml文檔  (example:data.xsl)
 xsl:output method="xml"  encoding="gb2312" media-type="text/xml" />
2.在新的窗口打開(kāi),給聯(lián)接增加屬性,指明目標(biāo)窗口為其他窗口  (example:data2.xsl)
 xsl:attribute name="target">_blank/xsl:attribute>


examples:


/*** data.xml ***/

?xml version="1.0" encoding="gb2312"?>
?xml-stylesheet type="text/xsl" href="data.xsl"?>
root>
 search>
  url>http://www.google.com/search?q=/url>
  word>xml數(shù)據(jù)/word>
 /search>
 search>
  url>http://www1.baidu.com/baidu?word=/url>
  word>xml數(shù)據(jù)/word>
 /search>
 search>
  url>http://www.google.com/search?q=/url>
  word>極限編程(xp)/word>
 /search>
 search>
  url>http://www1.baidu.com/baidu?word=/url>
  word>極限編程(xp)/word>
 /search>
/root>


/*** data.xsl ***/

?xml version="1.0" encoding="gb2312"?>
xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
!-- 去掉下面一句,將出現(xiàn)錯(cuò)誤 -->
xsl:output method="xml"  encoding="gb2312" media-type="text/xml" />

xsl:template match="/">
 xsl:apply-templates /> 
/xsl:template>

xsl:template match="search">
 xsl:element name="a">
  xsl:attribute name="href">xsl:value-of select="url" />xsl:value-of select="word" />/xsl:attribute>
  xsl:value-of select="word" />
 /xsl:element>
 br />
/xsl:template>

/xsl:stylesheet>


/*** data2.xsl ***/

?xml version="1.0" encoding="gb2312"?>
xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

xsl:template match="/">
 xsl:apply-templates /> 
/xsl:template>

xsl:template match="search">
 xsl:element name="a">
  xsl:attribute name="href">xsl:value-of select="url" />xsl:value-of select="word" />/xsl:attribute>
  !-- 去掉下面一句,將出現(xiàn)錯(cuò)誤 -->
  xsl:attribute name="target">_blank/xsl:attribute>
  xsl:value-of select="word" />
 /xsl:element>
 br />
/xsl:template>

/xsl:stylesheet>


標(biāo)簽:果洛 益陽(yáng) 寧夏 德州 黃石 拉薩 宿遷 西雙版納

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《包含中文字符的URL編碼問(wèn)題》,本文關(guān)鍵詞  包含,中文,字符,的,URL,編碼,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《包含中文字符的URL編碼問(wèn)題》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于包含中文字符的URL編碼問(wèn)題的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 伊吾县| 长丰县| 柞水县| 华蓥市| 凭祥市| 花垣县| 天气| 澄迈县| 凤阳县| 曲周县| 义马市| 东丽区| 宾阳县| 靖安县| 宁城县| 盘锦市| 仙居县| 尚义县| 京山县| 天水市| 南岸区| 井研县| 荣成市| 鲁甸县| 平和县| 祁阳县| 盐城市| 香港 | 专栏| 广西| 桓台县| 芜湖市| 定州市| 贡嘎县| 乌兰察布市| 枞阳县| 太和县| 汤阴县| 永丰县| 平遥县| 客服|