【发布时间】:2016-04-22 20:43:42
【问题描述】:
土耳其语字符显示为“?”并错误地插入了数据库。 我可以更改 phpmyadmin 中的文本并再次使其成为土耳其语。通过这种方式,一切都很完美。
我的编码过滤器:
private String encoding;
public void init(FilterConfig config) throws ServletException {
encoding = config.getInitParameter("requestEncoding");
if (encoding == null)
encoding = "UTF-8";
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain next) throws IOException, ServletException {
// Respect the client-specified character encoding
// (see HTTP specification section 3.4.1)
if (null == request.getCharacterEncoding())
request.setCharacterEncoding(encoding);
/**
* Set the default response content type and encoding
*/
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
next.doFilter(request, response);
}
public void destroy() {
}
我在 localhost 中没有土耳其字符问题。我只在 www.gurkanilleez.com 中看到问题。
【问题讨论】:
-
我解决了 jdbc:mysql://localhost:3306/dbname?characterEncoding=UTF-8 的问题,只是追加 'characterEncoding=UTF-8'
标签: java mysql tomcat encoding tomcat7