zDroid
zDroid

Reputation: 426

How do i create ServletContext in Spring

I wanted to add some values to the servletcontext, but am not sure how to get the object in spring. Can anyone please help

Upvotes: 3

Views: 642

Answers (2)

borjab
borjab

Reputation: 11675

See this answer.

Implementing the ServletContextAware interface will make Spring to inject the context.

@Controller
public class ServicesImpl implements Services, ServletContextAware{


private ServletContext context;

public void setServletContext(ServletContext servletContext) {
     this.context = servletContext;
}

Upvotes: 1

Andres
Andres

Reputation: 10727

Try this:

@Autowired
ServletContext servletContext;

Upvotes: 1

Related Questions