Versions Compared

Key

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

...

Setup the Web Application File Structure

Code Block
/mywebapptutorial/
/mywebapp/template/
/mywebapp/tutorial/META-INF/
/mywebapptutorial/WEB-INF/
/mywebapptutorial/WEB-INF/classes/
/mywebapptutorial/WEB-INF/lib/
/mywebapptutorial/WEB-INF/lib/CORE&OPTIONAL *.jar
/mywebapptutorial/WEB-INF/web.xml
  • Copy to your webapp/lib directory
    • the struts2-(VERSION).jar,
    • all the *.jar files in /lib/default, and
    • any necessary optional *.jar files from /lib/.

...

Code Block
titleweb.xml
<?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>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

The standard web.xml registers a FilterDispatcher to enable framework functionality for your requests. The ContextLoaderListener configures Spring as our dependency injection conitainer. The framework uses Spring internally, and you may wish to use it to deploy your own objects.

...