views:

329

answers:

4

is struts (1 or 2?) used strictly for MVC type architecture or is there more to it?

reason I am asking is I am looking at a web application and they seem to be using both spring and struts.

A: 

Spring was supporting Struts almost from the beginning. Struts is used as MVC (sorta DTO delivery mechanizm to the backend) and all the backend logic is handled by Spring providing IoC and mapping to the Struts. Read more here and here

DroidIn.net
so you can use either spring's mvc or struts?
mrblah
yes. You may actually use both - the question is why would you do that?
DroidIn.net
+1  A: 

Spring is a many-headed beast, and can be used for all kinds of applications, web and otherwise. When you use Spring for a web application, you can go all the way and use Spring's very own MVC framework for handling the web-specific portions of your application. But you don't have to. The back end aspects of Spring - that is, all the beans that make up the various components of your application and the various Spring tools you use with them (transaction management, security etc) can be used with any front end. Explicit plug-ins are available to integrate Spring with Struts, Struts 2, and some others, but even that is optional and you can use Spring without any MVC framework at all.

Dan
+6  A: 

To summarize:

  • Spring and Spring MVC are different things.
  • Spring is a dependency injection framework and an inversion of control container
  • Spring MVC is an MVC web framework
  • Struts is an MVC web framework as well
  • Spring MVC and Struts can't be used at the same time (well, perhaps they can, but it's not desirable)
  • Spring and Struts can be used at the same time - Struts providing the web layer, and Spring managing the service layer and its wiring to the web layer.
Bozho
+4  A: 

Is struts (1 or 2?) used strictly for MVC type architecture or is there more to it?

Hmm... Struts 2 (AKA WebWork 2) is a MVC framework like Spring MVC or Stripes Framework. They are all alternatives and target the presentation layer (and only the presentation layer).

Reason I am asking is I am looking at a web application and they seem to be using both spring and struts.

Using Struts 2 (or Stripes) doesn't exclude using Spring for Dependency Injection (and other services). In other words, you don't have to use Spring MVC at the presentation layer level to use Spring at other levels. Actually, most frameworks (this is at least true for Struts 2 and the Stripes framework) do provide nice Spring integration which is somehow something mandatory because of Spring popularity.

Pascal Thivent