[問題] JSP + MySQL + UTF-8 設定
※ [本文轉錄自 Wanted 看板]
作者: amike (沒有影子的貓) 看板: Wanted
標題: [問題] JSP + MySQL + UTF-8 設定
時間: Sat Sep 6 13:36:37 2008
請問用 JSP + MySQL 要怎設定
才能正常顯示中文
可以改的設定我幾乎都改了
不過中文還是亂碼
寫資料進 MySQL 也會出現錯誤
java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87'
MySQL 設定
[client]
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
utf8
utf8_general_ci
jdbc:mysql://localhost/sqldata?useUnicode=true&characterEncoding=utf-8
JSP 語法
<%@ page language="java" contentType="text/html; charset=utf8"
pageEncoding="utf8"%>
<% request.setCharacterEncoding("utf8"); %>
HTML 語法
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml">
湯姆貓設定 Sever.xml
<Connector executor="tomcatThreadPool"
port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.225.166.38
→
09/06 13:37,
09/06 13:37
→
09/06 13:38,
09/06 13:38
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.225.166.38
推
09/06 14:52, , 1F
09/06 14:52, 1F
推
09/06 15:34, , 2F
09/06 15:34, 2F
推
09/07 22:16, , 3F
09/07 22:16, 3F
推
09/07 22:39, , 4F
09/07 22:39, 4F
推
09/09 23:47, , 5F
09/09 23:47, 5F