Action class must be configured in the struts-config.xml file so that container must have the information for which action it has to forward to which Action class. That's is why we are configuring the Action classes. For each action from the JSP page we are writing each Action class, previously in servlet we were writing Servlet class for each action performed but in Struts we are writing simple Action class but capable of handling HttpServletRequest and HttpServletResponse because of overriding execute() method.

We are writing each action in < action > tag under the < action-mapping > tag .

struts-config.xml 

<form-beans>

   <form-bean name="loginForm" type="com.def.Struts.LoginForm">
   </form-bean>

<form-beans>

<action-mappings>
  
      <action path="/loginSubmit"
  name="loginForm"
  type="com.def.Struts.LoginAction"
  input="/login.jsp"> 
    
         <forward name="success" path="/home.jsp"></forward> 
         <forward name="failed" path="/login.jsp"></forward>

     </action>
<action-mappings>

Each Action is configured with each < action > tag but under < action-mapping > tag . So we can have multiple action tag in a single < action-mapping > tag , depending upon the action configured.

< action > tag

There are total 12 attributes of < action > tag but we are discussing of only 4 attributes. They are :
1. path
2. name
3. type
4. input

path : It represents the relative-path of the submitted request and it must be unique , must starts with  / . It also must be same as we write in the action attribute under the < from > tag .

name : It is the logical name which is used t identifies the name of the form bean which is coupled with the action performed.

type : It contains the fully qualified name of the Action class which is used to perform the respective action of the relative-path mentioned in the path attribute.

input : It represents the relative-path of the input form to which control must be returned if validation error is encountered.

< form-bean > tag

Form-bean tag has two attribute i.e name and type .

name : Name attribute contains the same name as we write in the name attribute of the action tag so that form bean must be coupled with the action performed.

type : In the type attribute , there must be full qualified name of the form bean.



1 comment:

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic