在我的应用程序中,我使用Spring,JPA Hibernate,JSF 问题是当我编写阿拉伯语文本并在类似于(ÙابÙÙÙ) 中找到它时我使用Tomcat v 7.0 Server托管bean中的阿拉伯文字
的web.xml
<filter>
<filter-name>encoding-filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
形式是
<h:form dir="rtl" acceptcharset="UTF-8">
头前
<?xml version="1.0" encoding="UTF-8"?>
In page of page。
<f:view locale="TR" encoding="UTF-8" contentType="text/html" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
我在托管bean @MangedBean
使用@Named
和@Component
都不对了。
MySQL数据库很好我从中读取阿拉伯文本正确。
在构造函数中,
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
try {
req.setCharacterEncoding("UTF-8");
res.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请任何暗示采取有效的阿拉伯文字。 在此先感谢。
很难了解您的具体问题的问题。你的意思是,当你在托管bean内部执行'System.out.println(input)'时,你在服务器日志中看到的是Mojibake而不是阿拉伯语?如果你忽略这一步骤,只是将输入保存在数据库中,那么它是否仍然是Mojibake或者它是否适合在数据库中使用阿拉伯语? – BalusC
顺便说一下,你不需要用大写字母来开始每一个单词。它使你的文本更难阅读。只有在句子开头和“JSF”,“休眠”等名字时才需要大写。尝试花更多时间阅读英文文章并查找/遵循相同的模式。 – BalusC
好的我会阅读英文文章:D –