@Override
public void init(FilterConfig filterConfig) throws ServletException {
ServletContext sc = filterConfig.getServletContext();
WebApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(sc);
if(cxt != null) {
if (publicService == null) {
publicService = cxt.getBean(PublicService.class);
}
}
}
原文:https://www.cnblogs.com/Marlo/p/15004988.html