我的JSP頁面未顯示拉丁字符。美洲變成了美國。 我已經把每個JSP的頂部:未顯示ISO-8859-1字符
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>`
,並在web.xml文件的頂部:
<?xml version="1.0" encoding="ISO-8859-1"?>
還試圖與數據庫的連接設置:
jdbc:mysql://localhost:3306/database3?charSet=ISO8859-1
而且我還它配置爲在項目的,但沒有成功特性ISO-8859-1,雖然我的數據庫表顯示就好了拉丁字符。
我錯過了什麼?
的狀態在我的數據庫是:
C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe Ver 14.14 Distrib 5.5.15, for Win32 (x86)
Connection id: 6
Current database: database3
Current user: [email protected]
SSL: Not in use
Using delimiter: ;
Server version: 5.5.15 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 12 min 22 sec
Threads: 2 Questions: 102 Slow queries: 0 Opens: 50 Flush tables: 1 Open tables: 27 Queries per second avg: 0.137
在我的表中的狀態是:
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| address | InnoDB | 10 | Compact | 4 | 4096 | 16384 | 0 | 16384 | 4194304 | 5 | 2011-09-07 18:46:49 | NULL | NULL | utf8_general_ci | NULL | | |
正如你所看到的,整理是utf8_general_ci
。
您是否包含元標記? –
@Daniel:無關緊要,當通過HTTP提供內容時忽略。 – BalusC
也許問題不是數據庫,而是Web容器?你有沒有檢查過[Tomcat的如何在任何地方使用UTF-8](http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q8) - 其他容器將有類似的文檔/程序。我傾向於在每個新項目中忘記我的'CharacterEncodingFilter'。 –