在jsp中通過jst的c:import>導入html時會出現亂碼的現象,其原因是org.apache.taglibs.standard.tag.common.core.ImportSupport
的charEncoding的值為空則會出現charEncoding為默認值也就是ISO-8859-1
所幸的是charEncoding可以直接通過c:import>直接設置,所以只需設置一下就好了,許多人說可以通過在html中通過meta設置contentType,但我試驗過卻不行,也是通過看jstl的源碼才發現可以設置這個,因為平時都是用cimport導入jsp,jsp中設置是可行的,但是靜態頁中卻不行。以下是ImportSupport的主要代碼:
復制代碼 代碼如下:
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";
}
}
您可能感興趣的文章:- c++ STL容器總結之:vertor與list的應用
- STL區間成員函數及區間算法總結
- C++在成員函數中使用STL的find_if函數實例
- jsp 使用jstl實現翻頁實例代碼
- STL 的string類怎么啦
- JSP和JSTL獲取服務器參數示例
- 關于STL中set容器的一些總結
- C++語言 STL容器list總結