Skip to end of metadata
Go to start of metadata


If for some reason the blank template or archetype doesn't work out, we can just setup an application from scratch.

Setup the Web Application File Structure

/tutorial/WEB-INF/lib/minimum JARs + any plugin JARs + plugin dependencies
  • Copy to your webapp/lib directory
    • the required JARs (see next section),
    • any Struts plugin JARs,
    • any plugin dependencies.

To customize the Struts templates (how HTML is rendered from the tags), copy into the application's webappdirectory the framework's /src/java/template directory.

Install the Minimum Set of Libraries and Configuration Files

The following files are a minium requirement for your application.




Framework library itself, found in distribution root directory


XWork 2 library on which Struts 2 is built (version 2.0 or later)


Object Graph Navigation Language (OGNL), the expression language used throughout the framework


Java bytecode manipulation library used by OGNL


All UI tag templates are written in Freemarker (also a good option for your own views)


Commons logging, which the framework uses to support transparently logging to either Log4J or JDK 1.4+


The Commons FileUpload package makes it easy to add robust, high-performance, file upload capability to your servlets and web applications.


Commons IO is a library of utilities to assist with developing IO functionality.


Commons Lang3 is used to simplify usage of common tasks and code shortcuts to to stay DRY


Java web application configuration file that defines the filters (and other components) for your web application


Framework configuration file that defines the actions, results, and interceptors for your application

If any Struts 2 Plugins are included, then other JARs may be needed too. For example, the optional Spring Plugin requires the Spring JARs to be present.

Setup the Web Application Deployment Descriptor (web.xml)

Create an web.xml file in [webapp]/WEB-INF (or merge into it the framework resources).

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

  <display-name>My Application</display-name>


The standard web.xml registers a FilterDispatcher to enable framework functionality for your requests.

If other packages are being used, like SiteMesh or Spring, then other filters may need to be configured too

(lightbulb) See also: Simple Setup

Setup the Struts Configuration (struts.xml)

Create a skeleton struts.xml file in /$APP/WEB-INF/classes.

    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<struts><!-- Configuration for the default package. -->
	<package name="default" extends="struts-default">

For now, the struts.xml just defines a default package (with the <package> section) where framework elements likeactionsresults and interceptors are registered.

(lightbulb) See also: Simple Setup


Onward to Simple Setup


Return to Simple Setup

  • No labels