利用 Java、塞莱、MySQL、Tomcat和Velocity采取了以下步骤:
- velocity.properties :
- input.encoding=UTF-8
- output.encoding=UTF-8
- server.xml
- URIEncoding = UTF-8
<html><head>
Charset- meta http-equiv="Content-Type" content="text/html;CHARSET=UTF-8"
- eclipse properties, project properties, file & editor encoding
- set all that apply to UTF-8
- JDBC connection:
- db.url=jdbc:mysql://:/?useEncoding=true&characterEncoding=UTF-8
- java/servlet code:
- request.setCharacterEncoding( UTF-8 )
上述所有工作都是徒劳的。 在以下法典出台之前:
private String getParameter(String key) {
String param = request.getParameter(key);
if (Util.isNotEmpty(param)) {
try {
return new String(param.getBytes("8859_1"), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return param;
}
return null;
}
以上意思是,<代码>request.setCharacterEncoding don t有效力(getCharacterEncoding(
)确实将UTF-8 退回;明知该请求的总结载于; 当地人代码>物体。
How is this caused and how can I solve it?