首页>代码>spring实例入门教程>/spring/src/abc/BaseFilter.java
package abc;


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class BaseFilter implements Filter{
	
	private ApplicationContext cont = null;
	
	public void destroy() {
	}
	
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		
		A a  = (A)cont.getBean("abc");
		System.out.println(a.getA());
		chain.doFilter(request, response);
		return;
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		cont = WebApplicationContextUtils.getWebApplicationContext( filterConfig.getServletContext() );
	}
	
}
最近下载更多
aaa最代码  LV14 2021年3月4日
anyiyi  LV11 2020年12月8日
llsama  LV9 2020年7月8日
一条小团团  LV4 2020年5月14日
twotwo  LV8 2020年1月1日
1412321161  LV4 2019年9月20日
3969138  LV15 2019年9月18日
mr赵晟齐  LV1 2019年9月4日
13476235384  LV16 2019年5月27日
松烟入墨2018  LV16 2019年3月18日
最近浏览更多
微信网友_6465435620184064  LV6 2023年10月24日
微信网友_6602457430806528  LV6 2023年8月12日
莫名奇妙的帅  LV4 2023年3月9日
1234hw  LV3 2022年11月20日
shaoxf_nihao  LV4 2022年5月31日
zhangwang1  LV1 2022年5月12日
笙歌的QQ邮箱  LV2 2022年3月2日
林青修  LV6 2022年1月29日
234士大夫士大夫但是  LV2 2022年1月11日
457229171  LV7 2021年12月12日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友