Controller in Struts

前端 未结 9 1895
滥情空心
滥情空心 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:32
    1. The predefined servlet class is the controller which uses structs-config.xml to manage or control your whole application.

    2. No, you can't have more than one controller in your struts application its just against the MVC rule (that you cant have more than one servlet in your app) struts is designed based on MVC.

    0 讨论(0)
  • 2021-01-12 06:36

    As we know if we are using MVC there must be a front end controller we should declare in web.xml . i.e in struts2 there are two filters available

    Front End controllers

    1)org.apache.struts2.dispatcher.FilterDispatcher 2)org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

    And these front end controller is responsible for loading struts.xml file

    In struts.xml each form name attributes are getting handled . After the operation is completed then controller will return to which page to be forwarded(Again this operation is taken care by front end controller).

    Hope it helps

    0 讨论(0)
  • 2021-01-12 06:43

    The controller is responsible for intercepting and translating user input into actions to be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations. The Controller receives the request from the browser, invoke a business operation and coordinating the view to return to the client.

    whenever the request for any resource comes, first it goes to the controller. In simple words we can say that controller is a navigator. And its job is to find the corresponding action class for the incoming request and transfer it to that particular action. Or in technical word we can say that it performs the mapping.

    he controller is implemented by a java servlet, this servlet is centralized point of control for the web application. In struts framework the controller responsibilities are implemented by several different components like

    The ActionServlet Class The RequestProcessor Class The Action Class

    for more reference on this you can go to the following link http://www.allapplabs.com/struts/struts_controller.htm

    0 讨论(0)
提交回复
热议问题