package filter;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Servlet Filter implementation class Encooding
 */
public class Encooding implements Filter {

    /**
     * Default constructor. 
     */
    public Encooding() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Filter#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub
	}

	/**
	 * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		String encooding=context.getInitParameter("encooding");
		request.setCharacterEncoding(encooding);
		response.setContentType("text/html;charset="+encooding);
		chain.doFilter(request, response);
	}

	/**
	 * @see Filter#init(FilterConfig)
	 */
	ServletContext context;
	public void init(FilterConfig fConfig) throws ServletException {
		context=fConfig.getServletContext();
	}

}
最近下载更多
赵鑫cdsaljkdfsa  LV11 2024年6月19日
abcdljw  LV20 2022年12月16日
lulululuping  LV1 2022年11月8日
liweb 010928  LV1 2022年10月31日
cqbscxh  LV11 2022年9月19日
ming_123_9715  LV23 2022年5月3日
李田所  LV1 2021年12月20日
儿童游戏机  LV9 2021年6月25日
928477320  LV1 2020年12月30日
dengge123  LV14 2020年9月14日
最近浏览更多
1w2e3r4t  LV1 3月7日
orang801  LV2 2月24日
sshiqi  LV2 2024年12月14日
sjwc88  LV3 2024年12月4日
lyt010628  LV4 2024年7月9日
曾显示  LV6 2024年7月7日
desdes  LV1 2024年6月24日
赵鑫cdsaljkdfsa  LV11 2024年6月19日
桸桸桸桸桸桸 2024年6月17日
暂无贡献等级
zeng1206  LV7 2024年6月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友