欧美国产另类久热|951超碰伊人久久|伊人影视久久久久|色婷婷亚洲小电影|色东京热69XX|婷婷玖玖深爱网|加勒比东京热网站|无码A级毛片在线观看|一级a毛一级a看|中文字幕人妻欧美

html 中文亂碼 HTML超鏈接中文亂碼問(wèn)題分析及解決方法
來(lái)源:易賢網(wǎng) 閱讀:2239 次 日期:2016-06-21 14:15:37
溫馨提示:易賢網(wǎng)小編為您整理了“html 中文亂碼 HTML超鏈接中文亂碼問(wèn)題分析及解決方法”,方便廣大網(wǎng)友查閱!

Vm中一個(gè)超鏈接URL需要拼接中文作為Get請(qǐng)求的參數(shù)。如果直接拼接,傳到后臺(tái)Action的參數(shù)對(duì)象中后取出會(huì)是亂碼,需要編碼后再拼接到URL上。

解決方法是在Action中添加一個(gè)成員變量,保存編碼后的中文參數(shù)。在vm頁(yè)面渲染時(shí)取出這個(gè)變量值,再拼接超鏈接。

在這里碰到的問(wèn)題是:調(diào)用java.net.URLEncoder的encode()方法時(shí),如果沒(méi)有顯示指定字符集參數(shù),那么URLEncoder會(huì)使用默認(rèn)字符集。這個(gè)默認(rèn)字符集在Eclipse里跑main()方法和在Tomcat里跑Web應(yīng)用,得到的結(jié)果不一樣,所以影響了編碼的結(jié)果。

代碼如下:

/**

* Translates a string into <code>x-www-form-urlencoded</code>

* format. This method uses the platform'sdefault encoding

* as the encoding scheme to obtain thebytes for unsafe characters.

*

* @param s <code>String</code> to betranslated.

* @deprecated The resulting string mayvary depending on the platform's

* default encoding. Instead, use theencode(String,String)

* method to specify the encoding.

* @return the translated <code>String</code>.

*/

@Deprecated

public static String encode(String s) {

String str = null;

try {

str = encode(s, dfltEncName);

} catch(UnsupportedEncodingException e) {

// The system should always have theplatform default

}

return str;

}

方法的注釋中也說(shuō)明了不建議使用的原因是,這個(gè)encode(String)方法依賴(lài)于平臺(tái)字符集。

更多信息請(qǐng)查看網(wǎng)頁(yè)制作
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢(xún)回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢(xún)?yōu)闇?zhǔn)!
相關(guān)閱讀網(wǎng)頁(yè)制作
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢(xún) | 簡(jiǎn)要咨詢(xún)須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)