You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 50 Next »

Preface

Struts 2 is a popular, easy-to-use MVC framework. This tutorial will help you get started with the framework, even if you are not an experienced Java web application developer. The tutorial will walk you through installing the framework and creating a simple application.

Be forewarned that the framework is geared toward professional developers. To create non-trivial applications, a working knowledge of several key technologies is required.

Supporting Technologies
  • Java
  • Servlets, JSP, and Tag Libraries
  • JavaBeans
  • HTML and HTTP
  • Web Containers (such as Tomcat)
  • XML

(lightbulb) For more about supporting technologies, see the Key Technologies Primer.

In this lesson, we download the framework and get started on an application of our own.

Download the Distribution

A distribution can be downloaded form the Apache Struts website. The full distribution contains the struts2.jar file and related dependencies, example applications, a copy of the documentation in HTML format, and the complete source code.

If you'd like to compile it yourself, please refer to Building the Framework from Source.

Your First Application

To get started on your own application, you can utilize the blank template, run the Maven archetype, or just setup your own from scratch.

Using the Blank Application

The blank web application in the distribution's apps directory is meant as a template. Make a copy of "blank" and use the copy as the basis for your application.

Run the Maven Archetype

mvn archetype:create -DgroupId=com.myCompany.mySystem \
                       -DartifactId=myWebApp \
                       -DarchetypeGroupId=org.apache.struts \
                       -DarchetypeArtifactId=struts2-archetype-starter \
                       -DarchetypeVersion=1.0-SNAPSHOT \
                       -DremoteRepositories=http://people.apache.org/maven-snapshot-repository

This will create the sample Web app template. For more information see Quickstart Using Maven 2

Setting up from scratch

If for some reason the blank template or archetype doesn't work for you, it's not so hard to setup a Struts 2 application from scratch. If you are interested, see Simple Setup.

Next

Onward to Hello World

Prev

Return to Step by Step

  • No labels