Versions Compared

Key

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

You can checkout this complete example project (and all the other Getting Started tutorial example projects) from the
Struts 2 subversion sandbox GitHub repository at https://svngithub.com/apache.org/repos/asf/struts/sandbox/trunkstruts-examples. The example projects use Maven
to manage the artifact dependencies and to build the .war files.

...

Code Block
xml
titlepom.xml build node
xml

	<build>
		<finalName>basic_struts</finalName>
	</build>

...

Code Block
xml
titlepom.xml dependency node
xml

<dependency>
	<groupId>org.apache.struts</groupId>
	<artifactId>struts2-core</artifactId>
	<version>X.X.X.X</version>
</dependency>

...

Code Block
xml
titlepom.xml log4j dependency node
xml

<dependency>
	<groupId>log4j</groupId>
	<artifactId>log4j</artifactId>
	<version>1.2.14</version>
</dependency>

...

Code Block
xml
titlelog4j.xml
xml

<?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"/> 
       </layout> 
    </appender>
 
    <!-- specify the logging level for loggers from other libraries -->
    <logger name="com.opensymphony">
    	<level value="DEBUG" />
    </logger>

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

...

Code Block
xml
titleweb.xml Servlet Filter
xml

<filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>struts2</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

...

Code Block
xml
titlestruts.xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

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

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

		<action name="index">
			<result>/index.jsp</result>
		</action>

	</package>

</struts>

...

Code Block
java
titleStruts 2 Log Messages
java

com.opensymphony.xwork2.DefaultActionProxy.debug:57 - Creating an DefaultActionProxy for namespace / and action name index
...
org.apache.struts2.dispatcher.ServletDispatcherResult.debug:57 - Forwarding to location /index.jsp

...