Apache Struts 2 Documentation > Home > Tutorials > Bootstrap > Ready, Set, Go! > Simple Setup |
If for some reason the blank template or archetype doesn't work out, we can just setup an application from scratch.
/tutorial/ /tutorial/META-INF/ /tutorial/WEB-INF/ /tutorial/WEB-INF/classes/ /tutorial/WEB-INF/lib/ /tutorial/WEB-INF/lib/minimum JARs + any plugin JARs + plugin dependencies /tutorial/WEB-INF/web.xml
To customize the Struts templates (how HTML is rendered from the tags), copy into the application's webapp directory the framework's /src/java/template directory. |
The following files are a minium requirement for your application.
Filename | Description |
---|---|
struts2-core.jar | Framework library itself, found in distribution root directory |
xwork.jar | XWork 2 library on which Struts 2 is built (version 2.0 or later) |
ognl.jar | Object Graph Navigation Language (OGNL), the expression language used throughout the framework |
freemarker.jar | All UI tag templates are written in Freemarker (also a good option for your own views) |
commons-logging.jar | Commons logging, which the framework uses to support transparently logging to either Log4J or JDK 1.4+ |
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 |
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.
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" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>My Application</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
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
See also: web.xml
Create a skeleton struts.xml file in /$APP/WEB-INF/classes.
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts><!-- Configuration for the default package. --> <package name="default" extends="struts-default"> ... </package> </struts>
For now, the struts.xml just defines a default package (with the <package> section) where framework elements like actions, results and interceptors are registered.
See also: struts.xml
Next | Onward to Hello World |
---|---|
Prev | Return to Ready, Set, Go! |