关于ssh编码问题

来源:互联网 发布:好听的网络红歌 编辑:程序博客网 时间:2024/06/05 00:22

  之前在写SSH时遇到编码问题,本来打算好好学一下的,老板的原因就夭折了,后来那个项目编码一堆乱,最近,公司来了个较牛B的,然后从他那学到了不少,这里就统一用UTF-8。

数据库

建表时

create database xxx character set utf8;


一、查看 MySQL 数据库服务器和数据库字符集的设置。


mysql> show variables like '%char%';

+--------------------------+-------------------------------------+------

| Variable_name | Value |......

+--------------------------+-------------------------------------+------

| character_set_client | utf8 |...... -- 客户端字符集

| character_set_connection | utf8 |......

| character_set_database | utf8 |...... -- 数据库字符集

| character_set_filesystem | binary |......

| character_set_results | utf8 |......

| character_set_server | utf8 |...... -- 服务器字符集

| character_set_system | utf8 |......

| character_sets_dir | D:\MySQL Server 5.0\share\charsets\ |......

+--------------------------+-------------------------------------+------

二、查看 MySQL 数据表(table) 的字符集。

mysql>show full columns from tablename;

mysql>show create table tablename;

mysql>show table status from sqlstudy_db like '%countries%';

+-----------+--------+---------+------------+------+-----------------+------

| Name | Engine | Version | Row_format | Rows | Collation |......

+-----------+--------+---------+------------+------+-----------------+------

| countries | InnoDB | 10 | Compact | 11 | utf8_general_ci |......

+-----------+--------+---------+------------+------+-----------------+------


连接数据库时

jdbc:mysql://localhost:3307/xxx?useUnicode=true&characterEncoding=utf-8
url后面加上
?useUnicode=true&characterEncoding=utf-8


struts2里的配置也要改成utf-8的

页面也改成utf-8的

pageEncoding="utf-8"


页面属性里的也改成utf-8

应该就没问题了

0 0
原创粉丝点击