Author: lukaszlenart
Date: Tue Sep 8 04:25:42 2015
New Revision: 964705
Log:
Updates production
Modified:
websites/production/struts/content/docs/webxml.html
Modified: websites/production/struts/content/docs/webxml.html
==============================================================================
--- websites/production/struts/content/docs/webxml.html (original)
+++ websites/production/struts/content/docs/webxml.html Tue Sep 8 04:25:42 2015
@@ -138,15 +138,37 @@ under the License.
<div class="pagecontent">
<div class="wiki-content">
- <div id="ConfluenceContent"><p>The <code>web.xml</code> web
application descriptor file represents the core of the Java web application, so
it is appropriate that it is also part of the core of the Struts framework. In
the <code>web.xml</code> file, Struts defines its FilterDispatcher, the Servlet
Filter class that initializes the Struts framework and handles all requests.
This filter can contain initialization parameters that affect what, if any,
additional configuration files are loaded and how the framework should
behave.</p><p>In addition to the FilterDispatcher, Struts also provides an
ActionContextCleanUp class that handles special cleanup tasks when other
filters, such as those used by Sitemesh, need access to an initialized Struts
framework.</p><h2 id="web.xml-SimpleExample">Simple Example</h2><p>Configuring
<code>web.xml</code> for the framework is a matter of adding a filter and
filter-mapping.</p><div class="code panel pdl" style="border-width: 1px;"><div
clas
s="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>FilterDispatcher Example (web.xml)</b></div><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><web-app id="WebApp_9" version="2.4"
- 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">
+ <div id="ConfluenceContent"><p>The <code>web.xml</code> web
application descriptor file represents the core of the Java web application, so
it is appropriate that it is also part of the core of the Struts framework. In
the <code>web.xml</code> file, Struts defines its FilterDispatcher, the Servlet
Filter class that initializes the Struts framework and handles all requests.
This filter can contain initialization parameters that affect what, if any,
additional configuration files are loaded and how the framework should
behave.</p>
+
+<p>In addition to the FilterDispatcher, Struts also provides an
ActionContextCleanUp class that handles special cleanup tasks when other
filters, such as those used by Sitemesh, need access to an initialized Struts
framework.</p>
+
+<h2 id="web.xml-KeyInitializationParameters">Key Initialization Parameters</h2>
+
+<p></p><p></p>
+<ul></ul><p></p>
+<ul><li><b>config</b> - a comma-delimited list of XML configuration files to
load.</li></ul><p></p>
+<ul><li><b>actionPackages</b> - a comma-delimited list of Java packages to
scan for Actions.</li></ul><p></p>
+<ul><li><b>configProviders</b> - a comma-delimited list of Java classes that
implement the
+ConfigurationProvider interface that should be used for building the
Configuration.</li></ul><p></p>
+<ul><li><b>loggerFactory</b> - The class name of the LoggerFactory
implementation.</li></ul><p></p>
+<ul><li><b>*</b> - any other parameters are treated as framework
constants.</li></ul><p></p>
+
+<p></p>
+
+<h2 id="web.xml-SimpleExample">Simple Example</h2>
+
+<p>Configuring <code>web.xml</code> for the framework is a matter of adding a
filter and filter-mapping.</p>
+
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>FilterDispatcher Example
(web.xml)</b></div><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<web-app id="WebApp_9" version="2.4"
+ 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">
<filter>
<filter-name>struts2</filter-name>
-
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.mycompany.myapp.actions</param-value>
@@ -161,23 +183,62 @@ under the License.
<!-- ... -->
</web-app>
-</pre>
-</div></div><div class="confluence-information-macro
confluence-information-macro-note"><p class="title">Changed Filter Structure in
Struts >= 2.1.3</p><span class="aui-icon aui-icon-small aui-iconfont-warning
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>To split up the the dispatcher
phases, FilterDispatcher is deprecated since Struts 2.1.3. If working with
older versions, you need to use</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"> ...
+]]></script>
+</div></div>
+
+ <div class="aui-message warning shadowed information-macro">
+ <p class="title">Changed Filter Structure in Struts >=
2.1.3</p>
+ <span class="aui-icon icon-warning">Icon</span>
+ <div class="message-content">
+
+<p>To split up the the dispatcher phases, FilterDispatcher is deprecated since
Struts 2.1.3. If working with older versions, you need to use</p>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+ ...
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
...
-</pre>
-</div></div><p>See <a shape="rect" href="sitemesh-plugin.html">SiteMesh
Plugin</a> for an example on when to use seperate Filters for prepare and
execution phase</p></div></div><div class="confluence-information-macro
confluence-information-macro-note"><p class="title">Why the Filter is mapped
with /* and how to configure explicit exclusions (since 2.1.7)</p><span
class="aui-icon aui-icon-small aui-iconfont-warning
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>In the example above we've mapped
the Struts 2 dispatcher to <code>/*</code>, so Struts 2 has a crack at all
incoming requests. This is because Struts 2 serves static content from its jar
files, including Dojo JavaScript files (if using S2.0, or the Dojo plugin in
S2.1+) and FreeMarker templates for the Struts 2 tags that produce
HTML.</p><p>If we change the filter mapping to something else, for example
<code>/*.html</code>, we must take this in to account and extract the content t
hat would normally be served from the Struts 2 jar files, or some other
solution.</p><p>Since Struts 2.1.7, you are able to provide a comma seperated
list of patterns for which when matching against the<br clear="none"> request
URL the Filter will just pass by. This is done via the configuration option
struts.action.excludePattern, for example in your struts.xml</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><struts>
- <constant name="struts.action.excludePattern"
value=".*unfiltered.*,.*\\.nofilter"/>
+]]></script>
+</div></div>
+<p>See <a shape="rect" href="sitemesh-plugin.html">SiteMesh Plugin</a> for an
example on when to use seperate Filters for prepare and execution phase</p>
+ </div>
+ </div>
+
+
+ <div class="aui-message warning shadowed information-macro">
+ <p class="title">Why the Filter is mapped with /* and how
to configure explicit exclusions (since 2.1.7)</p>
+ <span class="aui-icon icon-warning">Icon</span>
+ <div class="message-content">
+
+<p> In the example above we've mapped the Struts 2 dispatcher to
<code>/*</code>, so Struts 2 has a crack at all incoming requests. This is
because Struts 2 serves static content from its jar files, including Dojo
JavaScript files (if using S2.0, or the Dojo plugin in S2.1+) and FreeMarker
templates for the Struts 2 tags that produce HTML.</p>
+
+<p> If we change the filter mapping to something else, for example
<code>/*.html</code>, we must take this in to account and extract the content
that would normally be served from the Struts 2 jar files, or some other
solution.</p>
+
+<p> Since Struts 2.1.7, you are able to provide a comma seperated list of
patterns for which when matching against the<br clear="none">
+request URL the Filter will just pass by. This is done via the configuration
option struts.action.excludePattern, for example in your struts.xml</p>
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<struts>
+ <constant name="struts.action.excludePattern"
value=".*unfiltered.*,.*\\.nofilter"/>
...
</struts>
-</pre>
-</div></div></div></div><h2 id="web.xml-TaglibExample">Taglib
Example</h2><p>Typically, configuring a taglib is neither required nor
recommended. The taglib is included in <code>struts-core.jar</code>, and the
container will discover it automatically.</p><p><img class="emoticon
emoticon-tick"
src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/check.png"
data-emoticon-name="tick" alt="(tick)"> If, for some reason, a taglib
configuration is needed within web.xml, extract the TLD file from the
<code>struts-core.jar</code> <code>META-INF</code> folder, and add a
<code>taglib</code> element to the <code>web.xml</code>.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"> <!-- ... -->
+]]></script>
+</div></div>
+ </div>
+ </div>
+
+
+<h2 id="web.xml-TaglibExample">Taglib Example </h2>
+
+<p>Typically, configuring a taglib is neither required nor recommended. The
taglib is included in <code>struts-core.jar</code>, and the container will
discover it automatically.</p>
+
+<p><img class="emoticon emoticon-tick"
src="https://cwiki.apache.org/confluence/s/en_GB-1988229788/4109/76e0dbb30bc8580e459c201f3535d84f9283a9ac.1/_/images/icons/emoticons/check.png"
data-emoticon-name="tick" alt="(tick)"> If, for some reason, a taglib
configuration is needed within web.xml, extract the TLD file from the
<code>struts-core.jar</code> <code>META-INF</code> folder, and add a
<code>taglib</code> element to the <code>web.xml</code>.</p>
+
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+ <!-- ... -->
</welcome-file-list>
<taglib>
@@ -185,28 +246,44 @@ under the License.
<taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
</taglib>
</web-app>
-</pre>
-</div></div><h2
id="web.xml-CustomFileManagerandFileManagerFactoryimplementations">Custom
FileManager and FileManagerFactory implementations</h2><p>If there is a need to
support an App Server's specific file system (eg. VFS in JBoss), you can
implement your own version of FileManager. But it must be registered at "the
beginning" to support bootstrap of the whole framework.</p><p>To register your
own FileManger you can do it with <init-param/> as below:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><filter>
+]]></script>
+</div></div>
+
+<h2 id="web.xml-CustomFileManagerandFileManagerFactoryimplementations">Custom
FileManager and FileManagerFactory implementations</h2>
+
+<p>If there is a need to support an App Server's specific file system (eg. VFS
in JBoss), you can implement your own version of FileManager. But it must be
registered at "the beginning" to support bootstrap of the whole framework.</p>
+
+<p>To register your own FileManger you can do it with <init-param/> as
below:</p>
+
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<filter>
<filter-name>struts2</filter-name>
-
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.fileManager</param-name>
<param-value>com.company.MyFileManager</param-value>
</init-param>
</filter>
-</pre>
-</div></div><p>You can as well register your own FileManagerFactory with
<init-param/>, see example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><filter>
+]]></script>
+</div></div>
+
+<p>You can as well register your own FileManagerFactory with
<init-param/>, see example:</p>
+
+<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<filter>
<filter-name>struts2</filter-name>
-
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.fileManagerFactory</param-name>
<param-value>com.company.MyFileManagerFactory</param-value>
</init-param>
</filter>
-</pre>
-</div></div><p>Take a look on default implementations -
DefaultFileManager.java and DefaultFileManagerFactory.java to understand how
and why.</p></div>
+]]></script>
+</div></div>
+
+<p>Take a look on default implementations - DefaultFileManager.java and
DefaultFileManagerFactory.java to understand how and why.</p></div>
</div>