Using charset ISO-8859-1
encoding, jsf
Solution
You should not use the old ISO-8859-1 charset, but the new UTF-8 charset. JSF uses by default UTF-8 already which is much better prepared for world domniation.
Change everything to UTF-8 and change your IDE settings to use UTF-8 everywhere. In Eclipse, the most important setting is Window > Preferences > General > Workspace > Text File Encoding.
Then, enter "encoding" in the type filter text on the left top input field and re-apply the change to UTF-8 for all other settings as well.
See also:
- Unicode - How to get the characters right?
Problem
I'm from Brazil and here we have lots of `à` `é` `ô` `ó` `ç`, etc in our words and it is a problem on my JSF project. I have a `master.xhtml` as a template for all my pages and here it is: ``` <?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> ``` As you can see my xml encondig is correct as my `Content-Type` meta tag. I'm using Eclipse and on my project Properties->Resources I've changed the `Text file encoding` to ISO-8859-1. I have a label on my `login.xhtml` page that goes inside `master.xhtml` called Usuário (User), if I use the character `á`, and the word is wrong without it, I get this error: ``` 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) ``` Taking the `á` away it works but as I said, in Portuguese it is necessary and I'm gonna use a lot of other characters with accent.