Spring style controller programming

I come from experience with MVC frameworks, and recently I started to get interested in Spring. I think this is a good basis for what I have seen so far. Anyway, in my past experiences, I got used to a different programming style, especially for the controller structure. The way I used to use controllers was different. Of course, I somehow sketched a request on them (I thought about structures with different actions), but then I really liked that you could transfer actions to other controllers, then they would remain an “active” controller, and that would be responsible for processing the next request whether it can come from an HTTP request or from something else. I liked it because it was very convenient to save the state of the user's session in an automatic way, making the code clean and sharing different situations on different controllers. Now I read Spring Web MVC, and the docs only talk about controllers that respond to requests, but they don't save state and don't report chain controllers (other than forwarding) and state persistence.

How do you deal with these topics in spring, is there another way or should I implement my own state controllers and state / action classes?

I hope my question is clear enough, and I apologize for its breadth.

+7
source share
2 answers

In Spring MVC, you can use stateless controllers that redirect a beans session request / call session.

But if this is a good idea or not very much dependent on your use case. “I would only do this if I have only a few of these“ strange ”controllers. “If you have a lot of them, I think it's worth looking for another solution.” (e.g. JSF with Spring)

+5
source

In Java, the difference between stateful / stateeless web frames is usually described as the difference between an action-based and a component-based structure.

Both approaches are valid, but usually when you choose Framework you are stuck with this method:

The scope of popular actions:

Popular components:

(In both categories, of course, much more)

+8
source

All Articles