private FilterConfig filterConfig;
public void init(FilterConfig filterConfig) throws ServletException {
// Put your code here
this.filterConfig=filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
String encoding=this.filterConfig.getInitParameter("encoding");
request.setCharacterEncoding(encoding);
response.setContentType("text/html; charset=" + encoding);
chain.doFilter(request, response);
}
web.xml
EncodingFilter
zyz.EncodingFilter
encoding
utf-8
EncodingFilter
/*