This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-staging by this push: new 3083ae791 Updates stage by Jenkins 3083ae791 is described below commit 3083ae791c65f72cf5d63293003c37c53970f68e Author: jenkins <bui...@apache.org> AuthorDate: Thu Oct 20 09:24:44 2022 +0000 Updates stage by Jenkins --- content/core-developers/static-content.html | 46 ++++++++++++++++++----------- content/core-developers/web-xml.html | 27 ++++++++++------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/content/core-developers/static-content.html b/content/core-developers/static-content.html index 4f061a2a5..5944d6a46 100644 --- a/content/core-developers/static-content.html +++ b/content/core-developers/static-content.html @@ -135,17 +135,17 @@ <li><a href="#custom-static-content-loaders" id="markdown-toc-custom-static-content-loaders">Custom Static Content Loaders</a></li> <li><a href="#default-content-loader" id="markdown-toc-default-content-loader">Default Content Loader</a></li> <li><a href="#default-path" id="markdown-toc-default-path">Default path</a></li> - <li><a href="#preventing-struts-from-handling-a-request" id="markdown-toc-preventing-struts-from-handling-a-request">Preventing Struts from Handling a Request</a></li> + <li><a href="#preventing-struts-from-handling-a-request" id="markdown-toc-preventing-struts-from-handling-a-request">Preventing Struts from handling a request</a></li> </ul> -<p>Struts can serve static content like css and javascript files. This feature is enabled by default, but can be disabled +<p>Struts can serve static content like css and javascript files. This feature is enabled by default, but can be disabled by setting:</p> -<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.serve.static"</span> <span class="na">value=</span><span class="s">"false"</span> <span class="nt">/></span> +<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.serve.static"</span> <span class="na">value=</span><span class="s">"false"</span><span class="nt">/></span> </code></pre></div></div> <blockquote> - <p>If you disable this feature, but use the <code class="language-plaintext highlighter-rouge">xhtml</code>, or <code class="language-plaintext highlighter-rouge">css_xhtml</code> theme, make sure that the javascript and css files + <p>If you disable this feature, but use the <code class="language-plaintext highlighter-rouge">xhtml</code>, or <code class="language-plaintext highlighter-rouge">css_xhtml</code> theme, make sure that the javascript and css files shipped inside the core jar are extracted to your web application directory.</p> </blockquote> @@ -154,21 +154,22 @@ shipped inside the core jar are extracted to your web application directory.</p> <p>Static content is served by an implementation of <code class="language-plaintext highlighter-rouge">org.apache.struts2.dispatcher.StaticContentLoader</code>. To write your own <code class="language-plaintext highlighter-rouge">StaticContentLoader</code>, implement <code class="language-plaintext highlighter-rouge">StaticContentLoader</code> and define a bean for the class:</p> -<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.StaticContentLoader"</span> <span class="na">class=</span><span class="s">"MyStaticContentLoader"</span> <span class="na">name=</span><span class="s">"myLoader"</span> <span class="nt">/></span> -<span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.staticContentLoader"</span> <span class="na">value=</span><span class="s">"myLoader"</span> <span class="nt">/></span> +<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.StaticContentLoader"</span> <span class="na">class=</span><span class="s">"MyStaticContentLoader"</span> <span class="na">name=</span><span class="s">"myLoader"</span><span class="nt">/></span> +<span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.staticContentLoader"</span> <span class="na">value=</span><span class="s">"myLoader"</span><span class="nt">/></span> </code></pre></div></div> <h2 id="default-content-loader">Default Content Loader</h2> -<p>Struts provides a default implementation of <code class="language-plaintext highlighter-rouge">StaticContentLoader</code> which is <code class="language-plaintext highlighter-rouge">org.apache.struts2.dispatcher.DefaultStaticContentLoader</code>. -This loader will handle urls that start with “/static/” by default.</p> +<p>The Apache Struts provides a default implementation of <code class="language-plaintext highlighter-rouge">StaticContentLoader</code> which +is <code class="language-plaintext highlighter-rouge">org.apache.struts2.dispatcher.DefaultStaticContentLoader</code>. This loader will handle urls that start with “/static/” +by default.</p> -<p>This content loader can serve static content from the classpath, so when writing a plugin, you can put a file inside -your plugin’s jar like “/static/image/banner.jpg” and it will be served when the url “/static/image/banner.jpg” is +<p>This content loader can serve static content from the classpath, so when writing a plugin, you can put a file inside +your plugin’s jar like “/static/image/banner.jpg” and it will be served when the url “/static/image/banner.jpg” is requested.</p> <blockquote> - <p>This loader is not optimized to handle static content, and to improve performance, it is recommended that you extract + <p>This loader is not optimized to handle static content, and to improve performance, it is recommended that you extract your static content to the web application directory, and let the container handle them.</p> </blockquote> @@ -182,19 +183,28 @@ your static content to the web application directory, and let the container hand <p>This value is also used by the Default Content Loader.</p> -<h2 id="preventing-struts-from-handling-a-request">Preventing Struts from Handling a Request</h2> +<h2 id="preventing-struts-from-handling-a-request">Preventing Struts from handling a request</h2> -<p>If there is a request that Struts is handling as an action, and you wish to make Struts ignore it, you can do so by specifying -a comma separated list of regular expressions like:</p> +<p>If there is a request that Struts is handling as an action, and you wish to make Struts ignore it, +you can do so by specifying a comma separated list of regular expressions like:</p> -<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.action.excludePattern"</span> <span class="na">value=</span><span class="s">"/some/content/.*?"</span> <span class="nt">/></span> +<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.action.excludePattern"</span> <span class="na">value=</span><span class="s">"/some/content/.*,/other/content/.*"</span><span class="nt">/></span> </code></pre></div></div> -<p>These regular expression will be evaluated against the request’s URI (<code class="language-plaintext highlighter-rouge">HttpServletRequest.getRequestURI()</code>), and if any +<p>These regular expression will be evaluated against the request’s URI (<code class="language-plaintext highlighter-rouge">HttpServletRequest.getRequestURI()</code>), and if any of them matches, then Struts will not handle the request.</p> -<p>To evaluate each pattern Pattern class from JDK will be used, you can find more about what kind of pattern you can use -in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern">Pattern class JavaDoc</a>.</p> +<p>To evaluate each pattern the <code class="language-plaintext highlighter-rouge">Pattern</code> class from JDK will be used, you can find more about what kind of pattern you can +use in the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern">Pattern class JavaDoc</a>.</p> + +<p>Since Struts 6.1.0 you can use a custom separator. By default, the provided patterns are split using comma <code class="language-plaintext highlighter-rouge">,</code>, +but it can happen that you want to use comma in your patterns as well, e.g.: <code class="language-plaintext highlighter-rouge">/static/[a-z]{1,10}.json</code>. In such case +you can define a custom separator to be used to split the patterns, use <code class="language-plaintext highlighter-rouge">struts.action.excludePattern.separator</code> +constant:</p> + +<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.action.excludePattern.separator"</span> <span class="na">value=</span><span class="s">"//"</span><span class="nt">/></span> +<span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.action.excludePattern"</span> <span class="na">value=</span><span class="s">"/some/[a-zA-Z]{1,10}.json///other/content/.*"</span><span class="nt">/></span> +</code></pre></div></div> </section> </article> diff --git a/content/core-developers/web-xml.html b/content/core-developers/web-xml.html index 846ff7a1c..db403d3b1 100644 --- a/content/core-developers/web-xml.html +++ b/content/core-developers/web-xml.html @@ -153,10 +153,11 @@ should behave.</p> <p><strong>Filter Example (web.xml)</strong></p> -<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><web-app</span> <span class="na">id=</span><span class="s">"MyStrutsApp"</span> <span class="na">version=</span><span class="s">"2.4"</span> - <span class="na">xmlns=</span><span class="s">"http://java.sun.com/xml/ns/j2ee"</span> - <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span> - <span class="na">xsi:schemaLocation=</span><span class="s">"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"</span><span class="nt">></span> +<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><web-app</span> <span class="na">xmlns=</span><span class="s">"http://xmlns.jcp.org/xml/ns/javaee"</span> + <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span> + <span class="na">xsi:schemaLocation=</span><span class="s">"http://xmlns.jcp.org/xml/ns/javaee + http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"</span> + <span class="na">version=</span><span class="s">"3.1"</span><span class="nt">></span> <span class="nt"><filter></span> <span class="nt"><filter-name></span>struts2<span class="nt"></filter-name></span> @@ -186,7 +187,9 @@ see example:</p> <span class="nt"><filter></span> <span class="nt"><filter-name></span>struts2<span class="nt"></filter-name></span> <span class="nt"><filter-class></span>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter<span class="nt"></filter-class></span> + <span class="nt"></filter></span> ... +<span class="nt"></web-app></span> </code></pre></div></div> <h2 id="changed-filter-structure-in-struts--213">Changed Filter Structure in Struts >= 2.1.3</h2> @@ -201,20 +204,20 @@ versions, you need to use</p> ... </code></pre></div></div> -<p>See <a href="../plugins/sitemesh-plugin">SiteMesh Plugin</a> for an example on when to use seperate Filters for prepare -and execution phase</p> +<p>See <a href="../plugins/sitemesh-plugin">SiteMesh Plugin</a> for an example on when to use separate Filters for prepare +and execution phase.</p> <h2 id="exclude-specific-urls">Exclude specific URLs</h2> -<p>In the example above we’ve mapped the Struts 2 dispatcher to <code class="language-plaintext highlighter-rouge">/*</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>In the example above we’ve mapped the Struts 2 dispatcher to <code class="language-plaintext highlighter-rouge">/*</code>, so Struts has a crack at all incoming requests. +This is because Struts serves static content from its jar files, including Dojo JavaScript files (if using 2.0, +or the Dojo plugin in 2.1+) and FreeMarker templates for the Struts tags that produce HTML.</p> <p>If we change the filter mapping to something else, for example <code class="language-plaintext highlighter-rouge">/*.html</code>, we must take this into account and extract -the content that would normally be served from the Struts 2 jar files, or some other solution.</p> +the content that would normally be served from the Struts jar files, or some other solution.</p> <p>Since Struts 2.1.7, you are able to provide a comma separated list of patterns for which when matching against -the request URL the Filter will just pass by. This is done via the configuration option struts.action.excludePattern, +the request URL the Filter will just pass by. This is done via the configuration option <code class="language-plaintext highlighter-rouge">struts.action.excludePattern</code>, for example in your struts.xml:</p> <div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><struts></span> @@ -224,6 +227,8 @@ for example in your struts.xml:</p> <span class="nt"></struts></span> </code></pre></div></div> +<p>Read more in <a href="static-content">Static content</a>.</p> + <h2 id="taglib-example">Taglib Example</h2> <p>Typically, configuring a taglib is neither required nor recommended. The taglib is included in <code class="language-plaintext highlighter-rouge">struts-core.jar</code>, and