Struts-config.xml configuration File "Action-mappings" Elements of the detailed

Source: Internet
Author: User

Original address: http://blog.163.com/[email protected]/blog/static/11291097020105125537114/

Action-mappings

This element is used to define the action element into the Actionservlet class, which contains 0 to multiple <action/> elements in the following format:

<action-mappings>

<action path= "Action request relative path, same as page

Type= "full path to the corresponding class of the action"

Name= "Formbean of the action binding, consistent with <form-bean > 's Name property value"

<forward name= "Mapname" for the path= value returned by Mapping.findforward ("Mapname") in the action class, and the relative path of the page jump/>

</action>

</action-mappings>

Each action child element can contain one or more forward child elements. In addition to the path, type, and Name properties, the action has the following properties:

L Scope: Specifies the scope (session and request) of the Actionform Bean, which is the default session. (optional);

L Input: The path returned when the bean error occurred, the page that was incorrectly displayed in the Validate validation framework (optional);

L ClassName: Specifies the full name of the Actionmapping class that invokes this action class. Default with org.apache.struts.action.ActionMapping (optional);

L include: If there is no forward, it plays the role of forward (optional);

L Validate: If True, the Validate () method of Actionform is called or validate authentication is called, otherwise it is not called, and the default is true (optional).

The Forward property is also optional.

An example of an action element definition is as follows:

Example1.

Eg2. There is an example of the input attribute:

<action-mappings> <action

Path= "/useraction"

Type= "Com.amigo.struts.action.UserAction"

Name= "UserForm"

Scope= "Request"

Validate = "false"

Parameter= "Method" >

<forward name= "error" path= "/user/error.jsp"/>

<forward name= "Success" path= "/user/success.jsp"/>

<forward name= "Add" path= "/user/adduser.jsp"/>

<forward name= "Update" path= "/user/updateuser.jsp"/>

<forward name= "list" path= "/user/userlist.jsp"/>

</action>

</action-mappings>

Eg3. Only the action element of the JSP:

<action-mappings>

<action path= "/calcaction"

Type= "Com.amigo.struts.action.CalcAction"

Name= "Calcform"

Scope= "Request"

Validate= "true"

input= "/index.jsp" >

<forward name= "Success" path= "/success.jsp"/>
<forward name= "error" path= "/error.jsp"/>

</action>

</action-mappings>

First, Actionservlet calls the Execute () method of Forwardaction after receiving the request, and execute () forward to that URI based on the configured parameter property value.

<action path= "/menu"

Parameter= "/default.jsp"

Type= "Org.apache.struts.actions.ForwardAction"/>

The effect of this is that no form is instantiated, and a more realistic scenario might be that the form is defined in a higher level of request, or that the action is used as a system parameter after the application is compiled, and only needs to change the configuration file without recompiling the system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.