发布于 2016-08-15 06:05:21 | 191 次阅读 | 评论: 0 | 来源: 网友投递
JSP JAVA公司的WEB开发编程语言
JSP全名为Java Server Pages - java服务器页面是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML(标准通用标记语言的子集)文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件,后缀名为(*.jsp)。
在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";
}
}