Java 无法在网站中显示土耳其字符。Tomcat服务器,Mysql数据库
土耳其语字符显示为“?”并错误地插入了数据库。 我可以在phpmyadmin中更改文本,并再次将其设置为土耳其语。通过这种方式,一切都很完美 我的编码过滤器:Java 无法在网站中显示土耳其字符。Tomcat服务器,Mysql数据库,java,mysql,tomcat,encoding,tomcat7,Java,Mysql,Tomcat,Encoding,Tomcat7,土耳其语字符显示为“?”并错误地插入了数据库。 我可以在phpmyadmin中更改文本,并再次将其设置为土耳其语。通过这种方式,一切都很完美 我的编码过滤器: private String encoding; public void init(FilterConfig config) throws ServletException { encoding = config.getInitParameter("requestEncoding"); if (encoding ==
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中看到问题。每个非英语字符都有问号?可能发生的情况:
- 您有utf8编码的数据(良好)
已生效(默认,但错误)SET NAMES拉丁语1
- 列被声明为
(默认值,但错误)字符集latin1
?useUnicode=yes&characterEncoding=UTF-8
stackoverflow中有几个关于土耳其字符集问题的线程;阅读它们。由于我的声誉,我不能发表评论。我访问了你的网站,我看到了土耳其语字符,因为他们应该是。所以,没有问题,或者?我正在使用Hibernate。我尝试了您的解决方案,但没有任何效果将输入字段发送到数据库时出现问题。我解决了jdbc的问题:mysql://localhost:3306/dbname?characterEncoding=UTF-8只需附加“characterEncoding=UTF-8”