[英]Using charset ISO-8859-1
我來自巴西,在這里我們有很多的à
é
ô
ó
ç
等用我們的話,這是對我的JSF項目的問題。
我有一個master.xhtml
作為我所有頁面的模板,這里是:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta http-equiv="pragma" content="no-cache"/>
<link rel="stylesheet" href="#{facesContext.externalContext.requestContextPath}/assets/css/bootstrap.css" type="text/css" media="all" />
<title>#{masterController.projectName}</title>
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
</h:head>
<h:body>
<ui:fragment rendered="#{loginController.isLoggedIn}">
<ui:include src="../includes/top.xhtml"/>
</ui:fragment>
<ui:insert name="body" />
<hr />
<ui:fragment rendered="#{loginController.isLoggedIn}">
<ui:include src="../includes/footer.xhtml" />
</ui:fragment>
</h:body>
<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/js/bootstrap.min.js"></script>
</html>
正如您所看到的,我的xml encondig作為我的Content-Type
元標記是正確的。
我正在使用Eclipse和我的項目Properties-> Resources我已經將Text file encoding
更改為ISO-8859-1 。
我的login.xhtml
頁面上有一個標簽,位於login.xhtml
里面,名為master.xhtml
(用戶),如果我使用字符á
,如果沒有它,那么這個單詞是錯誤的,我收到此錯誤:
exception
javax.servlet.ServletException: null source
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
root cause
java.lang.IllegalArgumentException: null source
java.util.EventObject.<init>(Unknown Source)
javax.faces.event.SystemEvent.<init>(SystemEvent.java:67)
javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:69)
javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:69)
com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
服用á
遠離它的工作原理,但正如我所說,在葡萄牙有必要,我會使用很多的口音其它字符。
你不應該使用舊的ISO-8859-1字符集,而是使用新的UTF-8字符集。 JSF 默認使用UTF-8,它更適合世界統治。
將所有內容更改為UTF-8並更改IDE設置以在任何地方使用UTF-8。 在Eclipse中,最重要的設置是Window> Preferences> General> Workspace> Text File Encoding 。
然后,在左上方輸入字段的類型過濾器文本中輸入“encoding”,並將更改重新應用於UTF-8以用於所有其他設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.