Viren Pushpanayagam
Viren Pushpanayagam

Reputation: 2497

ServletContext and Spring MVC

How can I get the ServletContext inside an Interceptor in Spring MVC 3?

Upvotes: 46

Views: 50835

Answers (2)

axtavt
axtavt

Reputation: 242786

Since interceptor is a bean, you can simply autowire it:

@Autowired
ServletContext context;

Upvotes: 109

danny.lesnik
danny.lesnik

Reputation: 18639

Please look at this example

http://www.vaannila.com/spring/spring-interceptor.html

and then request.getSession().getServletContext()

Upvotes: 6

Related Questions