Struts Learning Note3 --- Action

xiaoxiao2021-03-18  206

To Develop your owte the following steps. That Steps Describe the minimum Actions That You Must Take WhenImum A New Action and Are The Focus of this section Section:

1.create a class there.

2. IMPLEMENT The Appropriate Execute () Method and add your specific business logic.

3.Compile The New Action and Move It Into The Web Application's ClassPath. This Would Most Offense.

4.Add an Element to the application's struts-config.xml file describing the new action.

Implementing the execute () Method:

The Execute () Method Has Two Functions:

Component Description ActionMapping Contains all of the deployment information for a particular Action bean. This class is to determine where the results of the LoginAction will be sent once its processing is complete. ActionForm Represents the Form inputs containing the request parameters from the View referencing this Action bean. The reference being passed to our LoginAction points to an instance of our LoginForm. HttpServletRequest A reference to the current HTTP request object. HttpServletResponse A reference to the current HTTP response object.

As You Build your OWN Action Objects, you will notice That The Almost All Perform The Same Sequence of Events.

1.cast The Actionform Reference Associated With Action To Your Specific Actionform Implementation. In The Previous The Passed-in Actionform Object To a SkeletonForm.

2.Add your specific business logic.

3.Use the ActionMapping.findForward () method to find the ActionForward object that matches the sub-element in the definition. We look at the sub-element in the following section.4.Return the Retrieved ActionForward Object. This Object Routes The Request to the appropriate view.

Configuring the means Class:

Attribute Description attribute Names a request or session scope attribute that is used to access an Action-Form bean, if it is other than the bean's specified "name". ClassName Names the fully qualified class name of the ActionMapping implementation class you want to use in when invoking this Action class. If the className attribute is not included, the ActionMapping defined in the ActionServlet's mapping initialization parameter is used. forward Represents a Module-relative path of the servlet or JSP resource that will process this request. This attribute is used if you do not want an Action to service the request to this path. The forward attribute is valid only if no include or type attribute is specified. include Represents a Module-relative path of the servlet or JSP resource that will process this request. This attribute IS Used if you do not want an action to service the request to this path. The include attribute is valid only if no forward or type attribute isbook ified. input Represents a Module-relative path of the input form to which control should be returned if a validation error is encountered. The input attribute is where control will be returned if ActionErrors are returned from the ActionForm or Action objects. (Optional) name Identifies the name of the form bean that is coupled with the Action being defined. path Represents the Module-relative path of the submitted request. The path must be unique and start with a / character. parameter A generic configuration parameter that is used to pass Extra information to the action Object defined by this action mapping. Roles a comma-delimited list of security roles That Can Access the defined

object. type Names the fully qualified class name of the Action class being described by this ActionMapping. The type attribute is valid only if no include or forward attribute is specified. scope Names the scope of the form bean that is bound to the described Action. The possible values ​​are request or session. The default value is session. unknown If set to true, this is used as the default action mapping when a request does not match another element. Only one ActionMapping can be marked as unknown per Module. validate If set to true, causes the ActionForm.validate () method to be called on the form bean associated to the Action being described. If the validate attribute is set to false, then the ActionForm.validate () Method is not called. The default value is true.a sample Sub-element sale some of the prep - element Using Some of the Previous Attributes Is Shown Here:

Type = "ch04.lookupaction"

Name = "lookupform"

INPUT = "/ index.jsp">

IT Performs The User-Defined Business Logic Associated With your application. It Tells The framework where it would next route the request.

The parameters of the action.execute () Method:

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

New Post(0)