Struts Different Action and ActionForm combinations

xiaoxiao2021-03-06  16

Explanation: Reading this article requires a certain Struts foundation. Note: The action in the text does not necessarily represent the specific Struts Action class, and sometimes refers to an integral action mapping. [1] Complete action name = "someform" infut = "somejsp.jsp" First, Struts's ActionServlet receives a request, then locate the corresponding mapping according to the configuration of Struts-Config.xml; next If the Form range is request or can't find this form in the defined range, create a new Form instance; get the form () method, then call its reset () method, then put the parameters in the form into the form, if the validate property Not false, call the validate () method; if validate () returns non-empty ActionerRors, it will be transferred to the URI specified by the input property, if returned to an empty ActionerRors, then execute the action () method, based on the ActionForward Determine the target URI. The effect of this is: execute () is only executed after Validate () successfully; the input property is specified by a URI. [2] Only Form's action First, Struts will search Someform in the defined Scope, if you find it, if you can't find a new instance; get the form () method, then call its RESET () method, then place the parameters in the form into the form, if the validate property Not false, call the validate () method; if validate () returns non-empty ActionerRors, it will be transferred to the URI specified by the input property, and if you return to the empty ActionerRorse, go to the target URI specified by the Parameter property. The effect of this is: No Action class can store our business logic, so all logic that needs to be written can only write to the form () or validate () method. The role of validate () is to verify and access the business layer. Because the action map here does not include Forward (meaningless), it cannot be redirected and can only be used with the default Forward. This Action only forms can be used to process data acquisition and forward to another JSP.

[3] Only an action action input = "somejsp.jsp" First, after the ActionServlet receives the request, obtain the Action class instance, call the execute () method; then find Forward, forward to specify in the configuration according to the ActionForward URI or Action. The effect of this is that there is no form instance being incorred to be incocute () method, so execute () must obtain parameters from the request. Action can be redirected by Forward or redirect. This Action cannot handle the request submitted by HTML Form, which can only handle the link-type request. [4] Only JSP action First, the ActionServlet receives the request to call ForwardAction's Execute ( Method, execute () is forward to that URI based on the configured parameter property value. The effect is that there is no form being instantiated, and the relatively realistic situation may be defined in the Request higher level; or this action is used as a system parameter after the application is compiled, only needs to change this The configuration file does not need to recompile the system. [5] Two Actions corresponds to a form name = "Someform" inform = "somejsp.jsp" name =" someform "infut =" someotherjsp.jsp " For each separate action, there is no substantial difference between processing and complete ACTION. This combination mode can be used to deliver the command object (FORM). It should be noted that the FORM RESET () and validate () methods are also called in the latter action, so we must ensure that the information in the form is not overwritten.

转载请注明原文地址:https://www.9cbs.com/read-45625.html

New Post(0)