|
在jsp中通過(guò)jst的<c:import>導(dǎo)入html時(shí)會(huì)出現(xiàn)亂碼的現(xiàn)象,其原因是org.apache.taglibs.standard.tag.common.core.ImportSupport
的charEncoding的值為空則會(huì)出現(xiàn)charEncoding為默認(rèn)值也就是ISO-8859-1
所幸的是charEncoding可以直接通過(guò)<c:import>直接設(shè)置,所以只需設(shè)置一下就好了,許多人說(shuō)可以通過(guò)在html中通過(guò)meta設(shè)置contentType,但我試驗(yàn)過(guò)卻不行,也是通過(guò)看jstl的源碼才發(fā)現(xiàn)可以設(shè)置這個(gè),因?yàn)槠綍r(shí)都是用cimport導(dǎo)入jsp,jsp中設(shè)置是可行的,但是靜態(tài)頁(yè)中卻不行。以下是ImportSupport的主要代碼:
復(fù)制代碼 代碼如下:
Reader r = null;
String charSet;
String charSet;
if ((this.charEncoding != null) && (!this.charEncoding.equals(""))) {
charSet = this.charEncoding;
}
else {
String contentType = uc.getContentType();
if (contentType != null) {
String charSet = Util.getContentTypeAttribute(contentType, "charset");
if (charSet == null) charSet = "ISO-8859-1";
}
else {
charSet = "ISO-8859-1";
}
}
jsp技術(shù):jsp中使用jstl導(dǎo)入html亂碼問(wèn)題解決方法,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。