Wednesday, February 1, 2012

MVC with Struts

In the earlier post on MVC, we learned the Model-View-Controller framework.

We also learned a way to pass the Model to the View in the next post.

There are certain things we did in the Controller that are applicable to most MVC style applications:
- Read form parameters
- Choose the View
- Pass the Model (or some other data) to the View

So the question arises:
Why not make a generic Controller that can do all these things?

In fact, why not write a framework that takes care of all the "MVC plumbing"?

Enter Struts.

Struts is a MVC framework. It allows you to declaratively "wire" the URLs/Controllers/Views, it parses all the form inputs, it makes it easy to pass data between Controllers and Views, it can validate user input, and do many other things.

It comes in two versions Struts 1 and Struts 2. We will play with both.