jsp中使用jstl導入html亂碼問題解決方法
在jsp中通過jst的<c:import>導入html時會出現(xiàn)亂碼的現(xiàn)象,其原因是org.apache.taglibs.standard.tag.common.core.ImportSupport
的charEncoding的值為空則會出現(xiàn)charEncoding為默認值也就是ISO-8859-1
所幸的是charEncoding可以直接通過<c:import>直接設置,所以只需設置一下就好了,許多人說可以通過在html中通過meta設置contentType,但我試驗過卻不行,也是通過看jstl的源碼才發(fā)現(xiàn)可以設置這個,因為平時都是用cimport導入jsp,jsp中設置是可行的,但是靜態(tài)頁中卻不行。以下是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";
}
}
相關文章
Jsp中解決session過期跳轉到登陸頁面并跳出iframe框架的方法
這里我們是介紹一個網(wǎng)站管理后臺三個框架頁面當我們的jsp定義的session變量超時時用戶點擊時自動退出框架頁面并跳到登錄頁面去了,下面我來給大家演示一個實例2013-08-08
Spring mvc實現(xiàn)Restful返回xml格式數(shù)據(jù)實例詳解
這篇文章主要介紹了spring mvc實現(xiàn)Restful返回xml格式數(shù)據(jù)的相關資料,需要的朋友可以參考下2017-03-03
詳解Spring Hibernate連接oracle數(shù)據(jù)庫的配置
這篇文章主要介紹了詳解Spring Hibernate連接oracle數(shù)據(jù)庫的配置的相關資料,需要的朋友可以參考下2017-06-06

