为什么有的JSp页面打开以后默认是简体中文(GB2312)编码的,有的是西欧(iso)编码的,西欧编码打开的就是乱码,要在浏览器上修改编码才能显示出来。
在文件里面已经加入了<% page contentType="text/html charset=GB2312 " %>
后来又在<head>标记下面加入了<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
还是不行,最不能理解的就是,有的文件打开以后默认是GB2312的,有的就默认的是西欧的 求解?
在文件里面已经加入了<% page contentType="text/html charset=GB2312 " %>
后来又在<head>标记下面加入了<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
还是不行,最不能理解的就是,有的文件打开以后默认是GB2312的,有的就默认的是西欧的 求解?
你还有连接servlet了吗?如果连接了,在servlet里面有编码也要写成GB2312就是让你整个项目有关编码的地方都要写成一致的哈
package com.filter;import java.io.IOException;import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class Filter implements javax.servlet.Filter { public void destroy() {
// TODO Auto-generated method stub
} public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest req = (HttpServletRequest) request ;
HttpServletResponse resp = (HttpServletResponse) response ;
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
} public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}}