Stripes is designed to require as little configuration as possible. To get it
up and running you simply need to configure the Stripes Filter and the Stripes
Dispatcher Servlet in your web application's web.xml. A pretty standard
configuration would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<filter>
<display-name>Stripes Filter</display-name>
<filter-name>StripesFilter</filter-name>
<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>StripesFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>StripesFilter</filter-name>
<servlet-name>StripesDispatcher</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>StripesDispatcher</servlet-name>
<servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StripesDispatcher</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
</web-app>
Next you'll need to drop stripes.jar into your classpath, usually in your /WEB-INF/lib
directory. This is the only compile-time dependency for developing with
Stripes. For deploying and running Stripes you will also need to copy the
following library files supplied with Stripes into your classpath:
-
commons-logging.jar (1.1) -
Apache
Commons
Logging
is used to provide an implementation agnostic logging interface.
-
cos.jar - the
com.oreilly.servlets
package, courtesy of Jason Hunter, is used to manage multi-part file
uploads as part of form submissions
The above libraries are all supplied in the Stripes distribution, and have
been tested with Stripes. More recent versions may work, but your mileage
may vary.
In addition, it's very helpful to be able to see the logging output of
Stripes. To do this you'll need to supply either a working
Log4J
setup, or another Commons Logging compatible setup. The Log4J jar, log4j-1.2.9.jar, is
distributed with Stripes. Sample Commons Logging and Log4J configuration
files follow:
The logging configuration files need to be placed in your classpath, for
example in /WEB-INF/classes.
The last piece to put in place is the StripesResources.properties; you'll want to copy that to /WEB-INF/classes
for now. StripesResources.properties is used (by default) to lookup error messages both for Stripes'
built in validations, and for any validation done in ActionBeans, and it has
to be available in the Classpath. An example fragment of the file follows:
# Validation error messages used by Stripes' built in type converters
converter.number.invalidNumber=The value ({1}) entered in field {0} must be a
valid number converter.byte.outOfRange=The value ({1}) entered in field {0}
was out of the range {2} to {3} converter.short.outOfRange=The value ({1})
entered in field {0} was out of the range {2} to {3}
converter.integer.outOfRange=The value ({1}) entered in field {0} was out of
the range {2} to {3} converter.float.outOfRange=The value ({1}) entered in
field {0} was out of the range {2} to {3}
converter.enum.notAnEnumeratedValue=The value "{1}" is not a valid value for
field {0} converter.date.invalidDate=The value ({1}) entered in field {0} must
be a valid date converter.email.invalidEmail=The value ({1}) entered is not a
valid email address