1)在servlet中wac
[code]public void init(ServletConfig config) throws ServletException {
super.init(config);
WebApplicationContext wac = WebApplicationContextUtils
.getWebApplicationContext(getServletContext());
XXXService service = (XXXService) wac
.getBean("beanName");
}[/code]
2)在filter得到wac,
[code]public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
WebApplicationContext wac = WebApplicationContextUtils
.getWebApplicationContext(request.getSession().getServletContext());
XXXService service = (XXXService) wac
.getBean("beanName");
}[/code]
[code]public void init(ServletConfig config) throws ServletException {
super.init(config);
WebApplicationContext wac = WebApplicationContextUtils
.getWebApplicationContext(getServletContext());
XXXService service = (XXXService) wac
.getBean("beanName");
}[/code]
2)在filter得到wac,
[code]public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
WebApplicationContext wac = WebApplicationContextUtils
.getWebApplicationContext(request.getSession().getServletContext());
XXXService service = (XXXService) wac
.getBean("beanName");
}[/code]