Ad (728x90)

Filled Under: , , ,

What are different types of Actions we have in Struts?

Action Controler Interview Questions Learn Struts
There are seven type of Action in struts and each have their own relevance and importance, Here we will discuss each and everyone, Please find below all of them:
  • Action
  • Include
  • Forward
  • Switch
  • Dispatch
  • LookupDispatch
  • MappingDispatch
Action Class:
Action is a simple action which extend Action Class and overri3de an execute method which is called by default when request calls the specific action. Below is the Code to create a class with xml(struts-config.xml) entery:

public final class SimpleActionExample extends Action {

public ActionForward execute(ActionMapping mapping
ActionForm form
HttpServletRequest request
HttpServletResponse response) throws Exception {
return dispatcher.execute(mapping form request response);
}


DispatchAction: DispatchAction is a action class, which extent the DispatchAction Class as stated below:
public final class ExampleDispatchAction extends DispatchAction {

public ActionForward create(ActionMapping mapping
ActionForm form
HttpServletRequest request
HttpServletResponse response) throws Exception {
return (mapping.findForward( success ));
}
}


struts-config.xml entry would be like below:


<action path= "/exampleDispatchAction" type= "com.bhanuapp.ExampleDispatchAction" name="formName""" scope= request input= "homeDef" parameter= "ActionName" >
<forward name= "success" path= "example/ActionTartget.jsp" />
</action>

In View Layer like jsp call this action as follows:

<html:link action="exampleDispatchAction?ActionName=create" >Create</html:link>

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

Please write to us here...

 

We are featured contributor on entrepreneurship for many trusted business sites:

  • Copyright © Tekhnologia™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.