SSM+mysql接收表情字段utf8mb4編碼問題

錯誤:incorrect string value: '\xF0\x9F\x8D\x91\xE5\xB0...' for column...

1.spring配置文件:
url=jdbc\:mysql\://localhost\:3306/db_abc?useUnicode\=true&characterEncoding\=UTF-8

2.修改需要存儲字符表情的字段字符集編碼爲utf8mb4

3.在需要插入字段的前面增加set NAMES 'utf8mb4',mybatis配置如下:
<update id="setCharacters" >
set NAMES 'utf8mb4'
</update>

@Override
public int addScore(HhtZqcjScore score) {
    scoreExtMapper.setCharacters();
    return scoreMapper.insert(score);
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章