I l @ ve RuBoard |
It's very easy to provide a complicated description of how MVC works. I'm going to try to provide a simple, if slightly incomplete version, using Struts as an example. Struts is an Apache model 2 implementation. Describing Struts is a bit of a chicken-and-egg problem because you're really developing three pieces of the application at once. But it might be easier to understand by looking at it first from the perspective of a finished site. NOTE Struts was written by Craig McClanahan of Sun Microsystems. I'm grateful to Craig for suggestions that he made regarding this chapter. Assume that all mistakes are mine and that all golden nuggets are his. A user loads myAccount.jsp, a normal JSP with some custom tag libraries loaded to support Struts. When the user clicks on a link or submits a form, instead of being sent directly going to another JSP, the data is copied from the request into an ActionForm object with properties that mirror the data that is being sent from the page ”this is the "model" part of MVC.
Next , control is passed to an Action object, which runs any business logic needed to complete the user's request and determines what page the user needs to go to next. Action returns an object to the Controller (Struts), which uses an XML file to determine what JSP to dispatch to based on the status returned from Action . Finally, the new JSP displays any results (the "view"), and sets up for the next user request. |
I l @ ve RuBoard |