首先
jdbc:mysql://localhost:3306/bbscs6?useUnicode=true&characterEncoding=utf8
解决输入中文的问题输出中文
package com.shishuo.topcourse.bean;import javax.servlet.http.HttpServlet;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import javax.servlet.http.*;
import java.io.IOException;public class SetEncodeFilter implements Filter {protected FilterConfig filterConfig = null;protected String defaultEncoding = null;/**//* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
this.filterConfig = arg0;
this.defaultEncoding = filterConfig.getInitParameter("utf8");
}/**//* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(
ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding(selectEncoding(request));
chain.doFilter(request, response);
}
public void destroy() {
this.defaultEncoding = null;
this.filterConfig = null;
}
protected String selectEncoding(ServletRequest request) {
return this.defaultEncoding;
}
}这样就可以了

解决方案 »

  1.   

    连数据库:j
    dbc:mysql://localhost/deoa?useUnicode=true&useUnicode=true&characterEncoding=GBKjsp:
    <%@ page language="java"  contentType="text/html;charset=GBK"%>
    <html><head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
      

  2.   

    <%@ page language="java"  contentType="text/html;charset=GBK"%>
    这个应该可以的
      

  3.   

    servlet中加入
    request.setCharacterEncoding("gb2312");jsp中加入:
    <%@ page language="java"  contentType="text/html;charset=GBK"%>
    <%
     request.setCharacterEncoding("gb2312");
    %>试试~~
      

  4.   

    同意楼上:
    如果是servlet就加入
    request.setCharacterEncoding("gb2312");如果是jsp就加入:
    <%@ page language="java"  contentType="text/html;charset=GBK"%>
    <%
     request.setCharacterEncoding("gb2312");
    %>你这个也就是天已社区,因该可以解决的。呵呵,记得给我们分哦
      

  5.   

    加上这个话就行了
    dbc:mysql://localhost/deoa?useUnicode=true&amp;useUnicode=true&amp;characterEncoding=GBK
      

  6.   

    jdbc:mysql://localhost/deoa?useUnicode=true&amp;useUnicode=true&amp;characterEncoding=GBKorout.print(new String(rs.getString("contactContent").getBytes("iso_8859_1"),"GBK")),你把iso_8859_1写成了iso8859_1
      

  7.   

    servlet中加入
    request.setCharacterEncoding("gb2312");jsp中加入:
    <%@ page language="java"  contentType="text/html;charset=GBK"%>
    <%
     request.setCharacterEncoding("gb2312");
    %>