• mybatis只能模糊查询英文不能查询中文


    解决方法:修改配置文件,最简单的完美修改方法,修改mysql的my.cnf文件中的字符集键值(注意配置的字段细节):

    1、在[client]字段里加入default-character-set=utf8,如下:
    1
    [client]
    2
    port = 3306
    3
    socket = /var/lib/mysql/mysql.sock
    4
    default-character-set=utf8


    2、在[mysqld]字段里加入character-set-server=utf8,如下:
    1
    [mysqld]
    2
    port = 3306
    3
    socket = /var/lib/mysql/mysql.sock
    4
    character-set-server=utf8


    3、在[mysql]字段里加入default-character-set=utf8,如下:
    1
    [mysql]
    2
    no-auto-rehash
    3
    default-character-set=utf8
    修改完成后,service mysql restart重启mysql服务就生效。

    再一查询OK了
    ------------------------------------------------------------------------------------------------------------------------------
    *下面的只需要修改mybatis的配置文件即可。可不用修改mysql的my.cnf文件

    问题三:

    数据源在配置时,编码转换格式配置出错。

    解决办法:

    修改mybatis配置文件中配置数据源模块:

    <property name="url" value="jdbc:mysql://localhost:3306/cloth?useUnicode=true&amp;characterEncoding=UTF-8"/>

    这里需要注意,一般时候,我们都习惯写成<property name="url" value="jdbc:mysql://localhost:3306/cloth?useUnicode=true&characterEncoding=UTF-8"/>,但是在XML文件中,它的编码规则决定要这么变换。

    在xml文件中有以下几类字符要进行转义替换:

    参考:http://m.blog.csdn.net/article/details?id=53485694

  • 相关阅读:
    机器学习实战第五章Logistic回归
    pyhton pandas库的学习
    pyhton numpy库的学习
    ISLR第8章The Basics of Decision Trees
    ISLR第10章 Unsupervised Learning
    吴恩达机器学习第5周Neural Networks(Cost Function and Backpropagation)
    ISLR第9章SVM
    ISLR第六章Linear Model Selection and Regularization
    ISLR第五章Resampling Methods(重抽样方法)
    ISLR第二章
  • 原文地址:https://www.cnblogs.com/kaiwen/p/6485243.html
Copyright © 2020-2023  润新知