This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-site by this push: new 7ffabcd42 Automatic Site Publish by Buildbot 7ffabcd42 is described below commit 7ffabcd42763ccb22ecd7d691a400d5e0f64b84c Author: buildbot <us...@infra.apache.org> AuthorDate: Fri Oct 21 07:55:07 2022 +0000 Automatic Site Publish by Buildbot --- output/core-developers/static-content.html | 46 +++++++++++++-------- output/core-developers/web-xml.html | 27 +++++++----- output/plugins/rest/index.html | 66 ++++++++++++++++++++---------- 3 files changed, 89 insertions(+), 50 deletions(-) diff --git a/output/core-developers/static-content.html b/output/core-developers/static-content.html index 4f061a2a5..5944d6a46 100644 --- a/output/core-developers/static-content.html +++ b/output/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/output/core-developers/web-xml.html b/output/core-developers/web-xml.html index 846ff7a1c..db403d3b1 100644 --- a/output/core-developers/web-xml.html +++ b/output/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 diff --git a/output/plugins/rest/index.html b/output/plugins/rest/index.html index 0e55cf604..f4eaaada0 100644 --- a/output/plugins/rest/index.html +++ b/output/plugins/rest/index.html @@ -153,6 +153,7 @@ </ul> </li> <li><a href="#advanced-topics" id="markdown-toc-advanced-topics">Advanced Topics</a> <ul> + <li><a href="#xstream-configuration" id="markdown-toc-xstream-configuration">XStream configuration</a></li> <li><a href="#custom-contenttypehandlers" id="markdown-toc-custom-contenttypehandlers">Custom ContentTypeHandlers</a></li> <li><a href="#settings" id="markdown-toc-settings">Settings</a></li> </ul> @@ -204,38 +205,38 @@ the Javadoc for the class, details this logic.</p> <p>This Restful action mapper enforces Ruby-On-Rails REST-style mappings. If the method is not specified (via <code class="language-plaintext highlighter-rouge">!</code> or <code class="language-plaintext highlighter-rouge">method:</code> prefix), the method is “guessed” at using REST-style conventions that examine the URL and the HTTP method. -Special care has been given to ensure this mapper works correctly with the codebehind plugin so that XML configuration +Special care has been given to ensure this mapper works correctly with the Convention plugin so that XML configuration is unnecessary.</p> <p>This mapper supports the following parameters:</p> <ul> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.idParameterName</code> - If set, this value will be the name of the parameter under which the id is stored. -The id will then be removed from the action name. Whether or not the method is specified, the mapper will try + <li><code class="language-plaintext highlighter-rouge">struts.mapper.idParameterName</code> - If set, this value will be the name of the parameter under which the id is stored. +The id will then be removed from the action name. Whether the method is specified, the mapper will try to truncate the identifier from the url and store it as a parameter.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.indexMethodName</code> - The method name to call for a GET request with no id parameter. Defaults to <strong>index</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.getMethodName</code> - The method name to call for a GET request with an id parameter. Defaults to <strong>show</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.postMethodName</code> - The method name to call for a POST request with no id parameter. Defaults to <strong>create</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.putMethodName</code> - The method name to call for a PUT request with an id parameter. Defaults to <strong>update</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.deleteMethodName</code> - The method name to call for a DELETE request with an id parameter. Defaults to <strong>destroy</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.editMethodName</code> - The method name to call for a GET request with an id parameter and the <strong>edit</strong> view specified. Defaults to <strong>edit</strong>.</li> - <li><code class="language-plaintext highlighter-rouge">struts.mapper.newMethodName</code> - The method name to call for a GET request with no id parameter and the <strong>new</strong> view specified. Defaults to <strong>editNew</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.indexMethodName</code> - The method name to call for a GET request with no id parameter. Defaults to <strong>index</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.getMethodName</code> - The method name to call for a GET request with an id parameter. Defaults to <strong>show</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.postMethodName</code> - The method name to call for a POST request with no id parameter. Defaults to <strong>create</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.putMethodName</code> - The method name to call for a PUT request with an id parameter. Defaults to <strong>update</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.deleteMethodName</code> - The method name to call for a DELETE request with an id parameter. Defaults to <strong>destroy</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.editMethodName</code> - The method name to call for a GET request with an id parameter and the <strong>edit</strong> view specified. Defaults to <strong>edit</strong>.</li> + <li><code class="language-plaintext highlighter-rouge">struts.mapper.newMethodName</code> - The method name to call for a GET request with no id parameter and the <strong>new</strong> view specified. Defaults to <strong>editNew</strong>.</li> </ul> <p>The following URL’s will invoke its methods:</p> <ul> - <li><code class="language-plaintext highlighter-rouge">GET: /movies</code> => method=<strong>index</strong></li> - <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers</code> => method=<strong>show</strong>, id=<strong>Thrillers</strong></li> - <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers;edit</code> => method=<strong>edit</strong>, id=<strong>Thrillers</strong></li> - <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers/edit</code> => method=<strong>edit</strong>, id=<strong>Thrillers</strong></li> - <li><code class="language-plaintext highlighter-rouge">GET: /movies/new</code> => method=<strong>editNew</strong></li> + <li><code class="language-plaintext highlighter-rouge">GET: /movies</code> => method=<strong>index</strong></li> + <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers</code> => method=<strong>show</strong>, id=<strong>Thrillers</strong></li> + <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers;edit</code> => method=<strong>edit</strong>, id=<strong>Thrillers</strong></li> + <li><code class="language-plaintext highlighter-rouge">GET: /movies/Thrillers/edit</code> => method=<strong>edit</strong>, id=<strong>Thrillers</strong></li> + <li><code class="language-plaintext highlighter-rouge">GET: /movies/new</code> => method=<strong>editNew</strong></li> <li><code class="language-plaintext highlighter-rouge">POST: /movies</code> => method=<strong>create</strong></li> - <li><code class="language-plaintext highlighter-rouge">PUT: /movies/Thrillers</code> => method=<strong>update</strong>, id=<strong>Thrillers</strong></li> - <li><code class="language-plaintext highlighter-rouge">DELETE: /movies/Thrillers</code> => method=<strong>destroy</strong>, id=<strong>Thrillers</strong></li> + <li><code class="language-plaintext highlighter-rouge">PUT: /movies/Thrillers</code> => method=<strong>update</strong>, id=<strong>Thrillers</strong></li> + <li><code class="language-plaintext highlighter-rouge">DELETE: /movies/Thrillers</code> => method=<strong>destroy</strong>, id=<strong>Thrillers</strong></li> </ul> -<p>To simulate the HTTP methods PUT and DELETE, since they aren’t supported by HTML, the HTTP parameter <code class="language-plaintext highlighter-rouge">_method</code> will be used.</p> +<p>To simulate the HTTP methods PUT and DELETE, since they aren’t supported by HTML, the HTTP parameter <code class="language-plaintext highlighter-rouge">_method</code> will be used.</p> <p>Or, expressed as a table:</p> @@ -302,7 +303,7 @@ in the following content types:</p> <ul> <li>HTML</li> - <li>XML </li> + <li>XML</li> <li>JSON</li> </ul> @@ -464,15 +465,38 @@ header and a last modified date so that the information will be cached properly is a convenient way to control the response in a type-safe way.</p> <p>Also, notice we aren’t returning the usual “success” result code in either method. This allows us to use the special -features of the <a href="../codebehind">Codebehind Plugin</a> to intuitively select the result template to process when this +features of the <a href="../convention">Conventio Plugin</a> to intuitively select the result template to process when this resource is accessed with the <code class="language-plaintext highlighter-rouge">.xhtml</code> extension. In this case, we can provide a customized XHTML view of the resource by creating <code class="language-plaintext highlighter-rouge">/orders-show.jsp</code> and <code class="language-plaintext highlighter-rouge">/orders-update.jsp</code> for the respective methods.</p> <h2 id="advanced-topics">Advanced Topics</h2> -<p>The following sections describe some of the non-standard bells and whistles that you might need to utilize for your +<p>The following sections describe some non-standard bells and whistles that you might need to utilize for your application’s more non-standard requirements.</p> +<h3 id="xstream-configuration">XStream configuration</h3> + +<p>Since Struts 6.1.0 you can customise XStream handler by implementing a few interfaces:</p> +<ul> + <li><code class="language-plaintext highlighter-rouge">XStreamAllowedClasses</code> - to control which classes can be accessed by the XStream</li> + <li><code class="language-plaintext highlighter-rouge">XStreamAllowedClassNames</code> - similar to the above but you can specify class names</li> + <li><code class="language-plaintext highlighter-rouge">XStreamPermissionProvider</code> - you can define a custom set of <code class="language-plaintext highlighter-rouge">TypePermission</code>s used by XStream</li> + <li><code class="language-plaintext highlighter-rouge">XStreamProvider</code> - you can create your own instance of <code class="language-plaintext highlighter-rouge">XStream</code> which will be used to serialise/deserialize objects</li> +</ul> + +<p>These interfaces need to be implemented by an action:</p> + +<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">private</span> <span class="kd">static</span> <span class="kd">class</span> <span class="nc">SimpleAction</span> <span class="kd">extends</span> <span class="nc">ActionSupport</span> <span class="kd">implements</span> <span class="nc">XStreamProvider</span> <span class="o">{</span> + <span class="nd">@Override</span> + <span class="kd">public</span> <span class="nc">XStream</span> <span class="nf">createXStream</span><span class="o">()</span> <span class="o">{</span> + <span class="nc">XStream</span> <span class="n">stream</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">XStream</span><span class="o">(</span><span class="k">new</span> <span class="nc">StaxDriver</span><span class="o">());</span> + <span class="n">stream</span><span class="o">.</span><span class="na">alias</span><span class="o">(</span><span class="s">"parents"</span><span class="o">,</span> <span class="nc">ArrayList</span><span class="o">.</span><span class="na">class</span><span class="o">);</span> + <span class="n">stream</span><span class="o">.</span><span class="na">alias</span><span class="o">(</span><span class="s">"data"</span><span class="o">,</span> <span class="nc">SimpleBean</span><span class="o">.</span><span class="na">class</span><span class="o">);</span> + <span class="k">return</span> <span class="n">stream</span><span class="o">;</span> + <span class="o">}</span> +<span class="o">}</span> +</code></pre></div></div> + <h3 id="custom-contenttypehandlers">Custom ContentTypeHandlers</h3> <p>If you need to handle extensions that aren’t supported by the default handlers, you can create your own <code class="language-plaintext highlighter-rouge">ContentTypeHandler</code>