主页 > 编程资料 > JSP(JAVA) >
发布时间:2016-01-01 作者:网络 阅读:238次

在jsp中通过jst的导入html时会出现乱码的现象,其原因是org.apache.taglibs.standard.tag.common.core.ImportSupport

的charEncoding的值为空则会出现charEncoding为默认值也就是ISO-8859-1

所幸的是charEncoding可以直接通过直接设置,所以只需设置一下就好了,许多人说可以通过在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";
        }
      }

关键字词: