Hey I'm new to Spring MVC, and I need some advice/clarification.
Currently I'm implementing an MVC application and I'm struggling with the scope of my controllers.
I scan all my controller classes via
<context:component-scan base-package="controller"/>
which is IMHO a very comfortable way.
Is it correct, that controllers(by default or scanned in the above way), are singletons just like an ordinary bean? If so, all membervariables of my controller are shared between several requests right? Can I change this? I would like to have request-scoped controllers. Just like:
<bean id="infoController" class="controller.InfoController" scope="request">
<constructor-arg ref="sessionFactory"/>
</bean>
Are there any side-effects with declaring my controllers as beans? Or is it an absolute no go to declare them like this? Or even declare them as request-scoped? Can I combine the two ways? something like:
<context:component-scan base-package="controller" scope="request"/>
How do you guys implement your controllers and make them "request-save"?