Controller in Struts

前端 未结 9 1965
滥情空心
滥情空心 2021-01-12 06:10

What is Controller in MVC ?

Is it struts.xml or Servlet (Action Class)?

Can we have more than one Controller in our ap

9条回答
  •  孤独总比滥情好
    2021-01-12 06:21

    As you will be knowing MVC stands for Model - View - Controller.

    Simply saying, Model contains our business components and logic, View contains our Presentation technology and Controller controls the flow of control and working of the application.

    In Struts

    There are two versions of Struts : Struts 1 and Struts 2.

    **These two are different frameworks.

    Struts 1 is based on Servlets. It has one ActionServlet that acts as its controller.

    Whereas in Struts 2 we have Filters. In this we can have Filter like FilterDispatcher or StrutsPrepareAndExecuteFilter that acts as our Controller.

    **In Struts 2, Actions act as Model.

    The main job of Controller is to decide which Action class will handle which request And controller does this with the help of Configuration defined by us in struts.xml file or by annotations in case of Struts 2.

提交回复
热议问题