I am having a problem when trying to input and save a Chinese string into MySQL via JSF and Hibernate.
Actually, I used "System.out.print" and detected garbled words happened, after typing 我(me) in JSF input field but before saving to database. Here is part of the code: index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Input"/>
<h:inputText value="#{showBean.input}" />
</h:panelGrid>
<h:commandLink action="#{showBean.show()}" value="Show"/>
</h:form>
</h:body>
</html>
ShowBean.java
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class showBean {
String input;
public showBean() {
input = null;
}
public String getInput() {
return input;
}
public void setInput(String input) {
System.out.println("set input " + input);
this.input = input;
}
public String show(){
System.out.println("show input " + input);
return "";
}
}
The console output is : set input ???è??è?????è??è????? show input ???è??è?????è??è?????