处理乱码问题
1、规范数据库和页面所有编码统一为一种例如utf-8
2、hibernate连接数据库设置连接编码
<session-factory>
<property name="connection.url">
jdbc:mysql://127.0.0.1:3306/leaveword?useUnicode=true&characterEncoding=utf-8
</property>
</session-factory>
3、提交数据前进行编码
String userName = new String (userName.getBytes("iso-8859-1","utf-8"))
或者加入过滤器
加入过滤器步骤
1)写一个过滤器类
2)配置web.xml