From 2eb36f60895cb617b8ff09544427ef78b9a3afc0 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Tue, 24 Mar 2015 00:30:07 +0800 Subject: [PATCH] Update 64.1. Add a Servlet, Filter or ServletContextListener to an application.md --- ...ervlet, Filter or ServletContextListener to an application.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/IX. ‘How-to’ guides/64.1. Add a Servlet, Filter or ServletContextListener to an application.md b/IX. ‘How-to’ guides/64.1. Add a Servlet, Filter or ServletContextListener to an application.md index e69de29..dbf3e82 100644 --- a/IX. ‘How-to’ guides/64.1. Add a Servlet, Filter or ServletContextListener to an application.md +++ b/IX. ‘How-to’ guides/64.1. Add a Servlet, Filter or ServletContextListener to an application.md @@ -0,0 +1,5 @@ +### 64.1. 为应用添加Servlet,Filter或ServletContextListener + +Servlet规范支持的Servlet,Filter,ServletContextListener和其他监听器可以作为`@Bean`定义添加到你的应用中。需要格外小心的是,它们不会引起太多的其他beans的热初始化,因为在应用生命周期的早期它们已经被安装到容器里了(比如,让它们依赖你的DataSource或JPA配置就不是一个好主意)。你可以通过延迟初始化它们到第一次使用而不是初始化时来突破该限制。 + +在Filters和Servlets的情况下,你也可以通过添加一个`FilterRegistrationBean`或`ServletRegistrationBean`代替或以及底层的组件来添加映射(mappings)和初始化参数。