Answer answer=(Answer) this.getHibernateTemplate().get(Answer.class,id);
System.out.println(answer.getAnswer());
answer.setCount(answer.getCount()+1);
this.getHibernateTemplate().update(answer);answer从数据库去出没有乱码,数据库编码是utf8的,为什么执行this.getHibernateTemplate().update(answer);
就出现乱码了呢?

解决方案 »

  1.   

    看看你的JDBC连接是不是设置了编码格式,是不是用相同编码。比如Mysql的连接:
    jdbc:mysql://localhost:3306/dbname?characterEncoding=UTF-8
      

  2.   

      1. 页面编码格式要改成Utf-8  
      2. 可以写个过滤器保证到后台是都是UTf-8
      3. 链接数据库要 useUnicode=true&characterEncoding=UTF-8
      

  3.   

    [Quote=引用 1 楼 samboy2002 的回复:]
    看看你的JDBC连接是不是设置了编码格式,是不是用相同编码。比如Mysql的连接:
    jdbc:mysql://localhost:3306/dbname?characterEncoding=UTF-8
    [/Qu
    正解