向数据库保存时乱码问题
首先在MYSQL上设置字符编码于UTF-8的最后一个选择,其次是设置JBOSS服务器的字符编码: <Connector protocol="HTTP/1.1" port="89" address="0.0.0.0"
connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8" />
页面上设置:普通的设置字符编码即可,格式为utf-8
在类文件中的字义: String str = new String("保存数据成功!");
Sring a;
try {
a = new String(str.getBytes(), "UTF-8");
setCreatedMessage(createValueExpression( a));
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(NewHomes.class.getName()).log(Level.SEVERE, null, ex);
}
数据库连接:?useUnicode=true&characterEncoding=UTF-8