I'm writing an application using jsf. My gradle dependencies:
我正在使用jsf编写应用程序。我的gradle依赖项:
[group: "commons-digester", name: "commons-digester", version: "2.1"],
[group: "com.sun.facelets", name: "jsf-facelets", version: "1.1.14"],
[group: "javax.faces", name: "jsf-api", version: "1.2_15"],
[group: "javax.faces", name: "jsf-impl", version: "1.2_15"],
[group: "javax.servlet", name: "jstl", version: "1.2"],
[group: "org.richfaces.framework", name: "richfaces-api", version: "3.3.3.Final"],
[group: "org.richfaces.framework", name: "richfaces-impl", version: "3.3.3.Final"],
[group: "org.richfaces.ui", name: "richfaces-ui", version: "3.3.3.Final"],
[group: "org.apache.poi", name: "poi", version: "3.2-FINAL"],
[group: "org.primefaces", name: "primefaces", version: "1.1"],
[group: "net.sf.json-lib", name: "json-lib", version: "2.4"],
[group: "commons-codec", name: "commons-codec", version: "1.5"],
[group: "mysql", name: "mysql-connector-java", version: "5.1.17"],
[group: "org.slf4j", name: "slf4j-api", version: "1.6.2"]
My jsp page outputs some text straight from bean, where it stored as String. When I use cyrillic string from properties - all looks fine. But when I use cyrillic string from bean field - I got something like
我的jsp页面直接从bean输出一些文本,它存储为String。当我从属性中使用西里尔字符串时 - 一切看起来都很好。但是当我使用来自豆田的西里尔字符串时 - 我得到了类似的东西
Rich datatable code:
丰富的数据表代码:
<rich:dataTable value="#{PrintForm.data}" var="invoize" align="center">
<rich:column colspan="#{invoize[0].colspan}" rowspan="#{invoize[0].rowspan}"
rendered="#{invoize[0].rendered}">
<h:outputText value="#{invoize[0].data}"/>
</rich:column>
<rich:column colspan="#{invoize[1].colspan}" rowspan="#{invoize[1].rowspan}"
rendered="#{invoize[1].rendered}">
<h:outputText value="#{invoize[1].data}"/>
</rich:column>
<rich:column colspan="#{invoize[2].colspan}" rowspan="#{invoize[2].rowspan}"
rendered="#{invoize[2].rendered}">
<h:outputText value="#{invoize[2].data}"/>
</rich:column>
<rich:column colspan="#{invoize[3].colspan}" rowspan="#{invoize[3].rowspan}"
rendered="#{invoize[3].rendered}">
<h:outputText value="#{invoize[3].data}"/>
</rich:column>
<rich:column colspan="#{invoize[4].colspan}" rowspan="#{invoize[4].rowspan}"
rendered="#{invoize[4].rendered}">
<h:outputText value="#{invoize[4].data}"/>
</rich:column>
<rich:column colspan="#{invoize[5].colspan}" rowspan="#{invoize[5].rowspan}"
rendered="#{invoize[5].rendered}">
<h:outputText value="#{invoize[5].data}"/>
</rich:column>
</rich:dataTable>
InvoiceBean code sample:
InvoiceBean代码示例:
this.invoiceData.add(Arrays.asList(
new TableCellData(1[colspan], 1[rowspan], true[rendered], "[Some cyrillic text]"),
new TableCellData(4, 1, true, "[Some cyrillic text]"),
new TableCellData(1, 1, false, ""),
new TableCellData(1, 1, false, ""),
new TableCellData(1, 1, false, "")
));
And on page in table cell I got:
在表格单元格的页面上,我得到了:
Дополнительная упаковка
Any ideas, please?
请问有什么想法吗?
Update
printForm.jsp starts with:
printForm.jsp以:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@ taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" %>
f:view>
<html>
<head><title><h:outputText value="[Cyrillic Text Displayed Ok]"/></title></head>
<body style="margin: auto; width: 800px;">
<h:form>
<rich:panel>
<center>
<h1>
[Cyrillic Text Displayed Ok]
</h1>
</center>
</rich:panel>
So, [Cyrillic Text Displayed Ok] is ok, but [Some cyrillic text] is wrong.
所以,[西里尔文本显示确定]没问题,但[某些西里尔文本]是错误的。
Notice: it's all ok when tomcat is running under Ubuntu Linux x64, but [Some cyrillic text] is wrong when Tomcat is running under Microsoft Windows 7 x86
注意:当tomcat在Ubuntu Linux x64下运行时,一切正常,但是当Tomcat在Microsoft Windows 7 x86下运行时,[某些西里尔语文本]是错误的
1 个解决方案
#1
0
Add the following to top of your JSP.
将以下内容添加到JSP的顶部。
<%@ page pageEncoding="UTF-8" %>
Or if you want to apply this on all JSPs, add the following entry to your web.xml
:
或者,如果要在所有JSP上应用此操作,请将以下条目添加到web.xml:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
See also:
- Unicode - How to get the characters right?
Unicode - 如何使角色正确?
#1
0
Add the following to top of your JSP.
将以下内容添加到JSP的顶部。
<%@ page pageEncoding="UTF-8" %>
Or if you want to apply this on all JSPs, add the following entry to your web.xml
:
或者,如果要在所有JSP上应用此操作,请将以下条目添加到web.xml:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
See also:
- Unicode - How to get the characters right?
Unicode - 如何使角色正确?