Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If for some reason the blank template or archetype doesn't work for you, here's how to out, we can just setup an application from square onescratch.

Setup the Web Application File Structure

...

  • Copy to your webapp/lib directory
    • the struts2-core-(VERSION).jar,
    • all the *.jar files in /lib/default, and
    • any necessary optional *.jar files from /lib/.
Tip

If you need to customize your own To customize the Struts templates (how HTML is rendered from Struts UI the tags), copy into your the application's webapp directory the framework's /src/java/template directory.

...

Filename

Description

struts2-core.jar

Framework library itself, found in distribution root directory

xwork.jar

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

oscore.jar

OSCore, a general-utility library from OpenSymphony

ognl.jar

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

commons-logging.jar

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

freemarker.jar

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

spring*.jar

The default dependency injection container for the framework.

web.xml

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

struts.xml

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

applicationContext.xml

Spring configuration file for any application Spring beans (may be empty).

The library files (*.jar) needs to be copied to your /mywebapp/WEB-INF/lib/ directory. If you need optional functionalities requiring dependencies on optional JARs, those JARs need to be copied to this directory too.

...

Code Block
titlestruts.xml
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts><!-- Include framework defaults (from Struts 2 JAR). -->
	<include file="struts-default.xml" />

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

For now, the struts.xml does only two things:

  • It tells the framework that it should import the configuration information from struts-default.xml. (This file is located at the root of the struts2-core.jar, so it is sure to be found.)

...

just defines a default package (with the <package> section) where framework elements like actions, results and interceptors are registered.

(lightbulb) See also: struts.xml

Next

Onward to Hello World

Prev

Return to Ready, Set, Go!