Struts functions-actionmapping object

Source: Internet
Author: User

In a web application, each resource must be referenced through a URI. Resources include HTML pages, JSP pages, and custom actions. To customize an action URI or path, the Struts framework provides an actionmapping object.

Actionmaping is also a core object of Struts. Generally, you do not need to write the actionmapping class. You only need to configure it in the configuration file.

How to configure actionmapping:

Actionmapping is configured in the profile Strtus-config.xml in the following format:

 

<struts-config><action-mappings><actionpath="/login"type="com.bjpowernode.struts.LoginAction"name="loginForm"                scope="request"                ><forwardname="success" path="/login_success.jsp" /><forwardname="error"path="/login_error.jsp"/>                </action></action-mappings></struts-config>

The <action> label is configured for each independent action, and their access mode and access control are configured.

<Forward> the location to be reached after the tag Configuration action is returned.

The name scope type is an attribute of actionmapping, which corresponds to the location and data source of the action and the data range.

 

Functions of actionmapping:

The main function of actionmapping is to manage the action information and the information of actionforward after the action is executed.

It maps specific requests to information related to specific actions and stores them in actionmapping. actionservelt transfers actionmapping to the action class execute () method. Action will use the findforward () method of actionmapping, this method returns an actionforward with the specified name, so that the action completes local forwarding. If no specific actionforward is found, a null value is returned.

 

Actionmapping method:

Publicexceptionconfig findexception (class type) to find the exception object

Public actionforwardfindforward (string name) can be dynamically added to the ing actionforward:

Public String [] findforwards () Find An actionforward list that can be used by an action

Public actionforwardgetinputforward () to get the input actionforard of this action.

Actionmapping inherits from org. Apache. Struts. config. actionconfig

 

In short, actionmapping is regarded as a data dictionary at the web control layer. The data dictionary stores the action and actionforward information. During program execution, you can view the data dictionary, then, the data dictionary is queried and specific information is forwarded.

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.