<%@ page contentType="text/html;chartset=GBK" %>
<meta http-equiv="Content-Type"content="text/html; charset=GBK">

解决方案 »

  1.   

    楼上的代码是不能解决问题的,因为这边的数据库都是用的8859-1的编码,所以页面也采用8859-1的,这样不需要每次存取数据都转换编码。现在重新填加了如下代码解决问题
    <%@ page language="java" import="java.util.*" pageEncoding="8859_1"%>
    <%@ page contentType="text/html; charset=8859_1" %>
    <% request.setCharacterEncoding("ISO-8859-1"); %>
    不过,不太明白这样设置和原来的设置有什么区别……
      

  2.   

    简体中文一般用gbk字符集避免乱码
      

  3.   

    <%@ page language="java" import="java.util.*" pageEncoding="8859_1"%>
    这句代码是设置jsp页面编码使用8859_1(ISO-8859_1)<%@ page contentType="text/html; charset=8859_1" %>
    这句代码是设置内容类型为"text/html"格式的编码为8859_1(ISO-8859_1)
    <% request.setCharacterEncoding("ISO-8859-1"); %>这句代码是设置请求自串编码为8859_1(ISO-8859_1)
    另外一种解决方法
    Response().setCharacterEncoding("gbk");//Response().setCharacterEncoding("gb2312");
    把从数据库中读取的数据转化转化成gbk(或gb2312)编码再写到页面上或给页面元素赋值;//new String(fromDBcontext..getBytes(), "gbk"));
    页面设置
    <%@ page contentType="text/html;chartset=GBK" %>
    <meta http-equiv="Content-Type"content="text/html; charset=GBK">
      

  4.   

    JSP页面全部加有<%@ page contentType="text/html;8859_1" %>和
    <meta http-equiv="Content-Type"content="text/html; charset=8859_1">HTML的页面是设置的<meta http-equiv="Content-Type"content="text/html; charset=GB2312">以上3句话我觉得必须保证是一样的编码格式,要不会出现问题...
      

  5.   

    在 JSP 头部加上 以下三行 应该能够搞定
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@page pageEncoding="gb2312" %>
    <%request.setCharacterEncoding("gb2312"); %>
      

  6.   

    <% request.setCharacterEncoding("ISO-8859-1"); %>
    应该是这句话起的作用ps:楼主做的纯英文的应用?