我在 mysql 中将数据存储为 ¥à¤¨à¥ à¤à¤°à¤¨à¥ 。它在 localhost 中工作正常,但在远程 mysql(在 plesk 中)它不工作。 我使用了以下内容:
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
在 servlet 中
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/projectkkm?useUnicode=yes&characterEncoding=UTF-8","root","");
在数据库连接中
<%@page pageEncoding="UTF-8" %>
在jsp中
现在根据我的研究,我发现问题出在 Java 中。 用于 linux 的 java 不支持印地文文本,请参阅 url:http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html
在我的本地主机 (Windows) 中它工作正常,但是当我将它部署到 centos(linux) 平台时它不工作。 我认为问题可能出在 window/linux 兼容性上。
谁能帮我解决这个问题。我确定问题不是来自 mysql 方面。
最佳答案
尝试添加,
<filter>
<filter-name>setCharacterEncodingFilter</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>setCharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在 web.xml 中
关于java - 无法使用java在mysql中存储印地语文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37366610/