本帖最后由 王少雷 于 2013-1-18 19:15 编辑
public class LanguageFilter extends HttpServlet implements Filter {
private static final long serialVersionUID = -7158070919202747452L;
private FilterConfig fconfig;
public void init(FilterConfig fconfig) throws ServletException {
this.fconfig=fconfig;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
try
{
String character=fconfig.getInitParameter("encoding");
if (character==null || "".equals(character)) character="utf-8";
request.setCharacterEncoding(character);
response.setCharacterEncoding(character);
filterChain.doFilter(request, response);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
这是我写的一个过滤器,你可以参考一下。配置文件里改成utf-8再试试。
|