Mihir Prakash
Mihir Prakash

Reputation: 11

How spring controller class object instantiated?

I have a question that, i have a spring-mvc based project which is accessible by multiple user. My question is that when more than one user access that application then for each user there is separate controller class object or all user access the same controller class object.

Upvotes: 1

Views: 2773

Answers (2)

Lee
Lee

Reputation: 738

If the controller is a bean (which is the usual case) then the default is one bean per Spring container context.

If you set the controller/bean to scope=prototype then you would get a new instance from the factory each time.

Upvotes: 1

user1933888
user1933888

Reputation: 3017

There will be multiple controller instances for different requests.

Please read: http://docs.spring.io/spring-framework/docs/2.5.x/reference/mvc.html

Related answer: How does Spring MVC handle multiple users

Upvotes: 1

Related Questions