Creating Struts actions

This documentation describes how to create a Struts action and optionally create an action mapping.

An action is an instance of an Action subclass that implements a portion of a Web application and returns a forward. An action mapping is a configuration file entry that, in general, associates an action name with an action.

To create an action and optionally create an action mapping, complete the following steps:

  1. In the Project Navigator of the Web perspective, right-click the name of a project.

  2. Left-click New > Other > Web > Struts > Action Class > Next. The New Action Class wizard starts.

  3. On the New Action Class page, complete the following steps:

    1. In the Java package field, specify the name of the Java package in which the class is to be created.

    2. In the Action class name field, type the name of the new action.

    3. If you want to specify modifiers that apply to the new class, select one or more of the following boxes: public, abstract, final.

    4. Make sure that a value is supplied in the Superclass field.

    5. For each interface that you want to create, click Add and type the interface name, the names of matching types, and any qualifiers.

    6. If you want to create method stubs, click the check boxes to select the ones you want.

    7. For the code generation model, select Generic Action Class.

    8. Click Next.

  4. If you want to create an action mapping in addition to creating an action, leave the Add new mapping box checked on the "Create a mapping for your Action class" page, and complete the following steps:

    1. Make sure that a configuration file name is specified.

    2. If you want to change the default mapping path, type the path name in the Mapping Path field.

    3. If you want forwards in addition to the defaults, click Add and type the name and path of the new forward.

    4. To delete a forward, select the forward name and click Remove.

    5. If you want to specify a form bean, select the name from the Form Bean Name drop-down menu.

    6. If you want to specify a form bean scope, from the Form Bean Scope drop-down list select request or session. The default behaves as if request were selected.

  5. Click Finish.

 

Related concepts

Struts actions and action mappings
Struts development tools

 

Related tasks

Creating Struts action mappings
Creating Struts form beans
Creating well-architected Web applications using Struts

Feedback