Spring Boot转换web.xml侦听器

Spring Boot转换web.xml侦听器,第1张

Spring Boot转换web.xml侦听器

对于RequestContext请阅读以下内容

 @Bean    @ConditionalOnMissingBean(RequestContextListener.class)    public RequestContextListener requestContextListener() {        return new RequestContextListener();    }

对于另一个侦听器,当您使用spring-boot时,该链接会自动注册。

对于您自己的听众。

public class MyAdditionListeners extends SpringBootServletInitializer {    protected final Log logger = LogFactory.getLog(getClass());    @Override    public void onStartup(ServletContext servletContext) throws ServletException {        WebApplicationContext rootAppContext = createRootApplicationContext(servletContext);        if (rootAppContext != null) { servletContext.addListener(new YourListenerHere());        }        else { this.logger.debug("No ContextLoaderListener registered, as "         + "createRootApplicationContext() did not "         + "return an application context");        }    }

最后一个链接,您可以在其中找到有关侦听器和SpringApplication类的信息。阅读部分



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5122782.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存