Announcement Announcement Module
No announcement yet.
Controllers: Why aren't they per-request by default? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controllers: Why aren't they per-request by default?

    Why did Spring MVC's designers decide that it is better to make controllers shared between requests by default?

    I mean, in the end it is all configurable, but IMHO it would have made more sense to made them per-request by default. At least I personally liked and found it very handy and sensible that Struts and WebWork were designed that way.

    After many years of using Spring, I still find it awkward that controllers do not have per-request scope by default. Is it a poor historical decision that is not changed for the sake of staying backwards compatible?

  • #2
    Struts and WebWork work in a different way as Spring MVC. WebWork combines the controller and model and as such needs a seperate instance per request. Spring has a clear seperation between the model and controller (as specified by MVC) and only the model should contain state and as such the controller is a perfect candidate to be a singleton.

    I'm basically on the other end of the spectrum, I found it quite ackward the way WebWork works . Spring, in the past, had the notion of a ThrowawayController which works in a similair manner as webwork but with newer versions of spring that became deprecated and eventually got removed.