我的环境是:Windows2000Server+MyEclipse4.0+Eclipse3.1+SqlServer2000+Hibernate3.0+Struts1.2,我在网上找了些文章,按他们的配置,可是都不起作用.我是这样配置的:
1.在Hibernate.cfg.xml配置文件中,加了下面的语句:
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">UTF</property>2.在jsp页面中,添加如下语句:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<META http-equiv="contentType" content="text/html; charset=UTF-8">3.过滤器:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}可还是出问题,添加的时候保存到SQLSERVER2000中的中文成了乱码,这是什么原因啊?

解决方案 »

  1.   

    设置
    hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory
      

  2.   

    TO:xlyyc(宇)
    请问
    hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory
    在哪儿设置啊?
      

  3.   

    你用hibernate.properties设置的吗?加在这个属性文件中啊
      

  4.   

    是不是jdbc本身的问题?同样的连接字符串,直接用jdbc连接数据库,保存中文乱码吗?
      

  5.   

    服务器用什么?
    如果是tomcat在server.xml的<Host>标签中加入
    <Host ...... URIEncoding="UTF-8">
      

  6.   

    to hugebrush() :
    以前用jdbc的时候没有问题的.
      

  7.   

    3.过滤器:
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    request.setCharacterEncoding("GB2312");
    chain.doFilter(request, response);
    }
      

  8.   

    少了html的:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    </body>
    </html>