日期:2014-05-16  浏览次数:20341 次

四位一体解决数据库乱码的问题

1. 前端设置编码方式:如 jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

2. 程序Server端设置编码方式,可以通过配置Filter的方式实现,在web.xml中配置如下:

<filter>

<filter-name>Set Character Encoding</filter-name>

<filter-class>com.chingcloud.demo.util.SetCharacterEncodingFilter</filter-class>

<init-param>

<param-name>encoding</param-name>

<param-value>UTF-8</param-value>

</init-param>

<init-param>

<param-name>ignore</param-name>

<param-value