The Action Mappings Configuration File in Struts Framework

The Action Mappings Configuration File in Struts Framework

Previous Home Next

 

ActionMapping contains your action definitions.You can used an <action> element for each of the mappings.We can define n-number of action sub element in the ActionMapping .The action sub element is describe an Action instance to ActionServlet.

 Each request should be mapped to an appropriate Action class and encapsulated in a ActionMapping.

The following attributes of the action sub element is:-

1.type:- 
This is Fully qualified Java class name of the Action.
2.name:- 
The name of the form bean bound this action.
3.path:- Thsi is context-relative path mapping action request.
4.validate:- If set to true if the validate method of the action associated with this mapping should be called.If the validate attribute is set to false then the validate method is not called.the default value is true.
5.forward:- forward passed the control when this mapping is invoked.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.
6.input :- it represent the context-relative path of the input form to which control should be return if a validation error is encountered.

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.r4r.struts.LoginForm"/>
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="login" path="/login.do"/>
</global-forwards>
<action-mappings>
<action path="/login" type="com.r4r.struts.LoginAction" name="loginForm">
<forward name="success" path="/success.jsp"/>
<forward name="error" path="/error.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.r4r.struts.ApplicationResources"/>
</struts-config> 


Previous Home Next