Developing Struts applications
A Struts-based Web application, also known as a Struts application, is a Web application that implements the Model-View Controller (MVC) design pattern by unifying the interaction of Java™ EE Web application components.
Struts is a framework for Web application development that helps you create well-architected applications. The Struts tools in this product make it easier for you to create and test a Struts-based Web application.
Using Struts to create a complex Web application can help make the application more maintainable. The application is easier to debug, easier to extend, and easier to understand. Using Struts tools can improve the efficiency by which you create the Struts-based application.
Struts applications use the Struts framework to implement a model-view-controller (MVC) design approach to building Web applications. As part of the controller portion of MVC, each Struts application has an action servlet that is configured in the deployment descriptor,
web.xml, of the application. For a Web application to be a Struts application, the action servlet must be configured and the appropriate resources must be in the Web project. Resources that are created automatically with a Struts-enabled Web project include:
- An
ApplicationResources.properties file in a subdirectory of the
JavaSource directory and in a subdirectory of the
WEB-INF directory
- Struts JAR files in the
lib directory in the
WEB-INF directory
- A Struts configuration file in the
WEB-INF directory
- Additional entries in the
.classpath file
To create a Struts application:
- Create a Struts enabled Web project. To enable Struts support, select the
Struts check box on the Project Facets page of the New Dynamic Web Project wizard.
Note: This product supports versions 1.0.2, 1.1x, 1.2x and 1.3x of the Apache Struts framework. If you have a dynamic Web project without Struts support, you can add Struts support.
- Design your Web application. The Struts tools work with the Web diagram editor.
- Create a Web diagram.
- Edit the Web diagram to create the resources needed for your application: Web pages, action mappings, Web applications, Struts modules, and Struts global exceptions and global forwards. Edit the Web diagram to include the logic flow between the resources in your application.
Tip: When working with the Page Designer, use the Page Data view to help you create forms and fields on a Web page from your form beans.
- Edit resource files. To edit the resource files, double-click the node and the associated resource opens in an editor. For example, when you create an action mapping node, an action mapping is created as well as the Java code referenced by the action. You must edit the Java code to include the logic for your Web application. To open resources related to the node, use the node pop-up menu.
- Test the application.
- Right-click the name of your initial Web page in the Web diagram editor or in the
Enterprise Explorer. In the pop-up menu, select
Run on Server.
- In the
Server selection window in the
Server type field, select the target runtime environment that you want to use and click Finish. The Web application server starts, and your initial Web page opens in a browser.
Related concepts
Struts framework and the model-view-controller design pattern