【发布时间】:2011-09-05 19:49:10
【问题描述】:
我的 JSP 页面没有显示拉丁字符。美国变成了美国。 我已经把每个 JSP 放在了上面:
<%@ 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: root@localhost
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 提供时会被忽略。
-
也许问题不在于数据库,而在于 Web 容器?你检查过Tomcat's How to use UTF-8 everywhere - 其他容器会有类似的文档/程序。我倾向于在每个新项目中忘记我的
CharacterEncodingFilter。 -
上面可以简单地应用于 ISO-8859-1,但就像 BalusC 说的:Go UTF-8。
标签: mysql jsp character-encoding iso-8859-1