1.About Struts2

1.1 The minimal required Struts 2 framework Jar files

  1. commons-fileupload-X.X.X.jar
  2. commons-io-X.X.X.jar
  3. commons-lang-X.X.jar
  4. commons-logging-X.X.X.jar
  5. commons-logging-api.X.X.jar
  6. freemarker-X.X.X.jar
  7. ognl-X.X.X.jar
  8. struts2-core-X.X.X.X.jar
  9. xwork-core-X.X.X.jar
  10. javassist-X.X.X.jar

1.2 To enable the Struts 2 framework to work with your web application you need to add a Servlet filter class and filter mapping to web.xml.

web.xml Servlet Filter


Note the url-pattern node value is /* meaning the Struts 2 filter will be applied to all URLs for this web application.


1.3 The minimal xml configuration. Note the file name is struts.xml and it should be in the src folder (struts.xml must be on the web application's root class path).

<?xml version="1.0" encoding="UTF-8"?>
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


	<constant name="struts.devMode" value="true" />

	<package name="basicstruts2" extends="struts-default">

		<action name="index">




1.4 Struts2 use flow

  1. Create a class to store the welcome message (the model)
  2. Create a server page to present the message (the view)
  3. Create an Action class to control the interaction between the user, the model, and the view (the controller)
  4. Create a mapping (struts.xml) to couple the Action class and view



2.About Log4J

2.1 Download path:    http://archive.apache.org/dist/logging/log4j/

2.2 Setup a log4j.xml configuration in the src folder.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
       <layout class="org.apache.log4j.PatternLayout"> 
          <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/> 
    <!-- specify the logging level for loggers from other libraries -->
    <logger name="com.opensymphony">
    	<level value="DEBUG" />

    <logger name="org.apache.struts2">
    	 <level value="DEBUG" />
   <!-- for all other loggers log only debug and above log messages -->
        <priority value="INFO"/> 
        <appender-ref ref="STDOUT" />