Create Struts action mappings

 

+

Search Tips   |   Advanced Search

 

An action mapping is a configuration file entry that usually contains a reference to an Action class. This entry can contain a reference to a form bean that the action can use, and can also define local forwards and exceptions that are visible only to this action.

Create a Struts enabled Web project or enable an existing Web project with Struts support.

A Struts action is an instance of a subclass of an Action class, which implements a portion of a Web application and whose perform or execute method returns a forward.

An action can perform tasks such as validating a user name and password or performing a computation. For an example of validating a user name and password, see /login in the struts-config.xml Struts configuration file in the struts-example sample application.

An action mapping is a configuration file entry that usually contains a reference to an Action class. This entry can contain a reference to a form bean that the action can use, and can also define local forwards and exceptions that are visible only to this action.

To create a Struts application, configure an action servlet in the deployment descriptor of the application. An action servlet is a servlet that is started by the servlet container of a Web server to process a request that invokes an action. The servlet receives a forward from the action and asks the servlet container to pass the request to the forward URL. An action servlet must be an instance of class...

org.apache.struts.action.ActionServlet

...or of a subclass of that class. An action servlet is the primary component of the controller. A default servlet is automatically added by the Struts tools when you add Struts support to a dynamic Web project.

A Struts action does not always require a form bean reference, depending on how the action is used in JSP files.

To create an action mapping that associates a Struts action with a forward: