加filter
代码如下:
package Servlet;
import javax.servlet.ServletResponse;
import javax.servlet.Filter;
import javax.servlet.ServletException;
import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.FilterChain;
import java.io.IOException;
public class Filter1 implements Filter
{
private FilterConfig _filterConfig = null;
public void init(FilterConfig filterConfig) throws ServletException
{
_filterConfig = filterConfig;
}
public void destroy()
{
_filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
request.setCharacterEncoding("GBK");
chain.doFilter(request, response);
}
}