1

My MVC concept is not clear.

It seems me that .xml files are for Modeling; .jsp files are for Viewing; .java files are for Controlling. This is actually represents MVC system.

I have the working basic concepts on MVC formula but I am not clear on which files are responsible specifically?

Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

1

First of all, dive into Wikipedia.

Your conception of MVC is wrong, and so is dividing concepts using technologies (.xml, .jsp, .java...);

enter image description here

  • The Model contains the data (WHAT is displayed);
  • The View renders the data to the user (HOW it is displayed);
  • The Controller manipulates the data, both automatically or based on user's interaction (WHY it is displayed).

Then, when you've clear what MVC is, try to understand how Struts2 implements MVC:

  • the JSP file is the View;
  • the Action is the Controller (and part of the Model);
  • the Model is whatever you use to carry the data (Bean, POJO, Map, String, etc...), unless you explicitly define a model object through ModelDriven (but don't), in which case that object is the Model.

EDIT: as suggested by Dave, it is worth mentioning that, when talking of Actions, we're also implying the StrutsPrepareAndExecuteFilter (responsible of which Action to call) and the Interceptor Stack (through which every Action must pass before - and after - a result execution).

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • (I'd argue the controller is the filter and the interceptors. Controllers decide what should handle requests.) – Dave Newton Apr 12 '17 at 11:38
  • @Dave yes, there're many interpretations where the Filter is presented as Controller and the Action as Model. Others says that the Filter (along with the interceptors) is a front-controller, and the action is the MVC controller in the strict sense... there's a lot of contamination between terms and concepts and a neat distinction is not always possible; I refuse the idea of [representing the Action as simply "the Model"](https://www.dunebook.com/5-best-java-framework-to-learn-in-2017/) though, and the term "Action" IMHO implies Filter and Stack too: an action cant' work without them – Andrea Ligios Apr 12 '17 at 12:17