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.