jsp中使用jstl导入html乱码问题解决方法
在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";
}
}
相关文章
Jsp中解决session过期跳转到登陆页面并跳出iframe框架的方法
这里我们是介绍一个网站管理后台三个框架页面当我们的jsp定义的session变量超时时用户点击时自动退出框架页面并跳到登录页面去了,下面我来给大家演示一个实例2013-08-08
Spring mvc实现Restful返回xml格式数据实例详解
这篇文章主要介绍了spring mvc实现Restful返回xml格式数据的相关资料,需要的朋友可以参考下2017-03-03
详解Spring Hibernate连接oracle数据库的配置
这篇文章主要介绍了详解Spring Hibernate连接oracle数据库的配置的相关资料,需要的朋友可以参考下2017-06-06


最新评论