1 jdbc连接
设置了characterencoding为UTF-8
jdbc.mysql.url=jdbc:mysql://localhost:3306/weboa?useUnicode=true&characterEncoding=UTF82 页面
<%@ include file="../commons/jsp/header.jsp" %>
而header.jsp里加入了
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
在页面里,点右键,查看编码方式为UTF-83 ACTION
保存在对象的属性里,调试的时候,可以看到正确显示4 使用p6spy查看sql语句为
update projects set PROJECT_NAME='搞笑不', PROJECT_STATUS='', REQUESTOR_CATEGORY='', REQUESTOR_CATEGORY_ID='AS', REQUESTOR_USER_NAME='', REQUESTOR_USER_ID=1, PROJECT_START_DATE=NULL, PROJECT_NOTE='', PRIORITY='0', SERIAID=1 where ID='20080610001'
在EMS SQL Manager里执行数据库正确显示...................5 数据库
mysql的DDL:
ENGINE=InnoDB DEFAULT CHARSET=utf8;一切都看起来正确,但就是从页面update进入action(正确),程序操作,存入mysql就是"???".
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
求解..............................................................................
设置了characterencoding为UTF-8
jdbc.mysql.url=jdbc:mysql://localhost:3306/weboa?useUnicode=true&characterEncoding=UTF82 页面
<%@ include file="../commons/jsp/header.jsp" %>
而header.jsp里加入了
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
在页面里,点右键,查看编码方式为UTF-83 ACTION
保存在对象的属性里,调试的时候,可以看到正确显示4 使用p6spy查看sql语句为
update projects set PROJECT_NAME='搞笑不', PROJECT_STATUS='', REQUESTOR_CATEGORY='', REQUESTOR_CATEGORY_ID='AS', REQUESTOR_USER_NAME='', REQUESTOR_USER_ID=1, PROJECT_START_DATE=NULL, PROJECT_NOTE='', PRIORITY='0', SERIAID=1 where ID='20080610001'
在EMS SQL Manager里执行数据库正确显示...................5 数据库
mysql的DDL:
ENGINE=InnoDB DEFAULT CHARSET=utf8;一切都看起来正确,但就是从页面update进入action(正确),程序操作,存入mysql就是"???".
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
求解..............................................................................
我的eclipse里查看页面的Info为Default (inherited from container :GBK)
5 数据库
mysql的DDL:
ENGINE=InnoDB DEFAULT CHARSET=utf8;
byte[] bytes =(lf.getUsername()).getBytes("拉丁编码");
username=new String(bytes,"UTF-8");
System.out.print("用户名12"+username+"#");}
catch(Exception e){
System.out.print("用户名2"+username); }
使用这个试试
直接在数据库里query到就是???
也就是说保存在mysql里就已经是???了
response.setCharacterEncoding("utf-8");
我使用MySQL Server Instance Config Wizard 重新配置,在设置Configure the MySQL Server 5.0 server instance那里的时候选择Manual Selected Default Character Set / Collation 为 UTF8 而不是默认的 LATIN1在MYSQL里查看得
mysql> \s;
--------------
E:\MySQL\MySQL Server 5.0\bin\mysql.exe Ver 14.12 Distrib 5.0.51a, for Win32 (ia32)Connection id: 2
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 25 secThreads: 1 Questions: 4 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.160
其中my.ini文件内容为
[mysql]default-character-set=utf8
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="E:/MySQL/MySQL Server 5.0/"#Path to the database root
datadir="E:/MySQL/MySQL Server 5.0/Data/"# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8...........