Spring DI in servlet

Today, I'll show you how can inject a bean into your servlet.

1. Using ServletContextListener

The ServletContextListener will enable your servlets to access the Spring ApplicationContext.



In your servlet :



2. Using the SpringBeanAutowiringSupport

I personally prefer the following solution :



thanks for sharing...

Comments

Popular posts from this blog

Spring JPA : Using Specification with Projection

Chip input using Reactive Form