托管 bean 中的阿拉伯语文本
Arabic text in managed bean
在我的应用程序中,我使用 Spring、JPA Hibernate、JSF
问题是当我写一个阿拉伯语文本并在像 (ÙابÙÙÙ) 这样的被管理的 Bean 中找到它时
我使用 Tomcat v 7.0 服务器
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"?>
在页眉中。
<f:view locale="TR" encoding="UTF-8" contentType="text/html" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
我在托管bean中使用@Named
@MangedBean
和@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();
}
请任何提示以获取有效的阿拉伯语文本。
提前致谢。
我在使用tomcat编码过滤器
时解决了这个问题
<filter>
<filter-name>SetCharacterEncoding</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>
<init-param>
<param-name>ignore</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter>
<filter-name>Conversation</filter-name>
<filter-class>org.jboss.weld.servlet.ConversationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Conversation</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在我的应用程序中,我使用 Spring、JPA Hibernate、JSF 问题是当我写一个阿拉伯语文本并在像 (ÙابÙÙÙ) 这样的被管理的 Bean 中找到它时 我使用 Tomcat v 7.0 服务器
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"?>
在页眉中。
<f:view locale="TR" encoding="UTF-8" contentType="text/html" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
我在托管bean中使用@Named
@MangedBean
和@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();
}
请任何提示以获取有效的阿拉伯语文本。 提前致谢。
我在使用tomcat编码过滤器
时解决了这个问题<filter>
<filter-name>SetCharacterEncoding</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>
<init-param>
<param-name>ignore</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter>
<filter-name>Conversation</filter-name>
<filter-class>org.jboss.weld.servlet.ConversationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Conversation</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>