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 c5e2af4 Updates stage by Jenkins c5e2af4 is described below commit c5e2af4e2d6e5bfbaaeeffa32ac9f4011320aefb Author: jenkins <bui...@apache.org> AuthorDate: Wed Feb 19 07:47:29 2020 +0000 Updates stage by Jenkins --- content/core-developers/action-configuration.html | 2 +- content/core-developers/default-properties.html | 11 ++ content/core-developers/interceptors.html | 17 +- content/core-developers/struts-default-xml.html | 17 +- content/tag-developers/checkboxlist-tag.html | 2 +- content/tag-developers/tag-syntax.html | 186 +++++++++++----------- 6 files changed, 126 insertions(+), 109 deletions(-) diff --git a/content/core-developers/action-configuration.html b/content/core-developers/action-configuration.html index ce881da..35b5878 100644 --- a/content/core-developers/action-configuration.html +++ b/content/core-developers/action-configuration.html @@ -212,7 +212,7 @@ to setting this property to <code class="highlighter-rouge">true</code>.</p> <p>Although action naming is pretty flexible, one should pay attention when using dots (eg. create.user) and/or dashes (eg. my-action). While the dot notation has no known side effects at this time, the dash notation will cause problems with the generated JavaScript for certain tags and themes. Use with caution, and always try to use camelcase action -names (eg. createUser) or underscores (eg. my-action).</p> +names (eg. createUser) or underscores (eg. my_action).</p> <p><strong>Allowed action names</strong></p> diff --git a/content/core-developers/default-properties.html b/content/core-developers/default-properties.html index fd6b3ac..447bfa1 100644 --- a/content/core-developers/default-properties.html +++ b/content/core-developers/default-properties.html @@ -366,6 +366,17 @@ struts.ognl.enableExpressionCache=true ### Indicates if Dispatcher should handle unexpected exceptions by calling sendError() ### or simply rethrow it as a ServletException to allow future processing by other frameworks like Spring Security struts.handle.exception=true + +### Applies maximum length allowed on OGNL expressions for security enhancement (optional) +### +### **WARNING**: If developers enable this option (by configuration) they should make sure that they understand the implications of setting +### struts.ognl.expressionMaxLength. They must choose a value large enough to permit ALL valid OGNL expressions used within the application. +### Values larger than the 200-400 range have diminishing security value (at which point it is really only a "style guard" for long OGNL +### expressions in an application. Setting a value of null or "" will also disable the feature. +### +### NOTE: The sample line below is *INTENTIONALLY* commented out, as this feature is disabled by default. +# struts.ognl.expressionMaxLength=256 + ### END SNIPPET: complete_file</code></pre></figure> diff --git a/content/core-developers/interceptors.html b/content/core-developers/interceptors.html index 29e063a..81763ab 100644 --- a/content/core-developers/interceptors.html +++ b/content/core-developers/interceptors.html @@ -248,8 +248,8 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t <span class="c"><!-- When declaring beans in this file you must either use name="struts" or don't name the bean at all. - The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.DefaultBeanSelectionProvider} - - it is then the default bean's name and {@link org.apache.struts2.config.DefaultBeanSelectionProvider} links name "struts" + The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.StrutsBeanSelectionProvider} - + it is then the default bean's name and {@link org.apache.struts2.config.StrutsBeanSelectionProvider} links name "struts" with "default" (aliasing it) If name won't be defined then the "default" value will be used {@link com.opensymphony.xwork2.inject.Container#DEFAULT_NAME} @@ -270,6 +270,7 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t java.lang.ClassLoader, java.lang.Shutdown, java.lang.ProcessBuilder, + sun.misc.Unsafe, com.opensymphony.xwork2.ActionContext"</span> <span class="nt">/></span> <span class="c"><!-- this must be valid regex, each '.' in package name must be escaped! --></span> @@ -280,13 +281,21 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t <span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.excludedPackageNames"</span> <span class="na">value=</span><span class="s">" ognl., + java.io., + java.net., + java.nio., javax., freemarker.core., freemarker.template., + freemarker.ext.jsp., freemarker.ext.rhino., + sun.misc., sun.reflect., javassist., + org.apache.velocity., org.objectweb.asm., + org.springframework.context., + com.opensymphony.xwork2.inject., com.opensymphony.xwork2.ognl., com.opensymphony.xwork2.security., com.opensymphony.xwork2.util."</span> <span class="nt">/></span> @@ -322,16 +331,13 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.multipart.MultiPartRequest"</span> <span class="na">name=</span><span class="s">"jakarta"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest"</span> <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.multipart.MultiPartRequest"</span> <span class="na">name=</span><span class="s">"jakarta-stream"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest"</span> <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.views.TagLibraryDirectiveProvider"</span> <span class="na">name=</span><span class="s">"s"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.DefaultTagLibrary"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.views.TagLibraryModelProvider"</span> <span class="na">name=</span><span class="s">"s"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.DefaultTagLibrary"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.freemarker.FreemarkerManager"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.velocity.VelocityManager"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="na">optional=</span><span class="s">"true"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.TemplateEngineManager"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"ftl"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.FreemarkerTemplateEngine"</span> <span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"vm"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.VelocityTemplateEngine"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"jsp"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.JspTemplateEngine"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"com.opensymphony.xwork2.conversion.impl.XWorkConverter"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="na">class=</span><span class="s">"com.opensymphony.xwork2.conversion.impl.XWorkConverter"</span> <span class="nt">/></span> @@ -417,7 +423,6 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"redirect"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.ServletRedirectResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"redirectAction"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.ServletActionRedirectResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"stream"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.StreamResult"</span><span class="nt">/></span> - <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"velocity"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.VelocityResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"xslt"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.xslt.XSLTResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"plainText"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.PlainTextResult"</span> <span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"postback"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.PostbackResult"</span> <span class="nt">/></span> diff --git a/content/core-developers/struts-default-xml.html b/content/core-developers/struts-default-xml.html index 0efbc91..d679948 100644 --- a/content/core-developers/struts-default-xml.html +++ b/content/core-developers/struts-default-xml.html @@ -165,8 +165,8 @@ setting in <a href="struts-properties.html">struts.properties</a>.</p> <span class="c"><!-- When declaring beans in this file you must either use name="struts" or don't name the bean at all. - The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.DefaultBeanSelectionProvider} - - it is then the default bean's name and {@link org.apache.struts2.config.DefaultBeanSelectionProvider} links name "struts" + The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.StrutsBeanSelectionProvider} - + it is then the default bean's name and {@link org.apache.struts2.config.StrutsBeanSelectionProvider} links name "struts" with "default" (aliasing it) If name won't be defined then the "default" value will be used {@link com.opensymphony.xwork2.inject.Container#DEFAULT_NAME} @@ -187,6 +187,7 @@ setting in <a href="struts-properties.html">struts.properties</a>.</p> java.lang.ClassLoader, java.lang.Shutdown, java.lang.ProcessBuilder, + sun.misc.Unsafe, com.opensymphony.xwork2.ActionContext"</span> <span class="nt">/></span> <span class="c"><!-- this must be valid regex, each '.' in package name must be escaped! --></span> @@ -197,13 +198,21 @@ setting in <a href="struts-properties.html">struts.properties</a>.</p> <span class="nt"><constant</span> <span class="na">name=</span><span class="s">"struts.excludedPackageNames"</span> <span class="na">value=</span><span class="s">" ognl., + java.io., + java.net., + java.nio., javax., freemarker.core., freemarker.template., + freemarker.ext.jsp., freemarker.ext.rhino., + sun.misc., sun.reflect., javassist., + org.apache.velocity., org.objectweb.asm., + org.springframework.context., + com.opensymphony.xwork2.inject., com.opensymphony.xwork2.ognl., com.opensymphony.xwork2.security., com.opensymphony.xwork2.util."</span> <span class="nt">/></span> @@ -239,16 +248,13 @@ setting in <a href="struts-properties.html">struts.properties</a>.</p> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.multipart.MultiPartRequest"</span> <span class="na">name=</span><span class="s">"jakarta"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest"</span> <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.dispatcher.multipart.MultiPartRequest"</span> <span class="na">name=</span><span class="s">"jakarta-stream"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest"</span> <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.views.TagLibraryDirectiveProvider"</span> <span class="na">name=</span><span class="s">"s"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.DefaultTagLibrary"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.views.TagLibraryModelProvider"</span> <span class="na">name=</span><span class="s">"s"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.DefaultTagLibrary"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.freemarker.FreemarkerManager"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.velocity.VelocityManager"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="na">optional=</span><span class="s">"true"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.TemplateEngineManager"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"ftl"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.FreemarkerTemplateEngine"</span> <span class="nt">/></span> - <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"vm"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.VelocityTemplateEngine"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"org.apache.struts2.components.template.TemplateEngine"</span> <span class="na">name=</span><span class="s">"jsp"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.components.template.JspTemplateEngine"</span> <span class="nt">/></span> <span class="nt"><bean</span> <span class="na">type=</span><span class="s">"com.opensymphony.xwork2.conversion.impl.XWorkConverter"</span> <span class="na">name=</span><span class="s">"struts"</span> <span class="na">class=</span><span class="s">"com.opensymphony.xwork2.conversion.impl.XWorkConverter"</span> <span class="nt">/></span> @@ -334,7 +340,6 @@ setting in <a href="struts-properties.html">struts.properties</a>.</p> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"redirect"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.ServletRedirectResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"redirectAction"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.ServletActionRedirectResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"stream"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.StreamResult"</span><span class="nt">/></span> - <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"velocity"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.VelocityResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"xslt"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.views.xslt.XSLTResult"</span><span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"plainText"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.PlainTextResult"</span> <span class="nt">/></span> <span class="nt"><result-type</span> <span class="na">name=</span><span class="s">"postback"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.result.PostbackResult"</span> <span class="nt">/></span> diff --git a/content/tag-developers/checkboxlist-tag.html b/content/tag-developers/checkboxlist-tag.html index eafea7d..e79687c 100644 --- a/content/tag-developers/checkboxlist-tag.html +++ b/content/tag-developers/checkboxlist-tag.html @@ -535,7 +535,7 @@ Everything else will result in <code class="highlighter-rouge">listkey</code> an <td align="left" valign="top">String</td> - <td align="left" valign="top">The name to set for element</td> + <td align="left" valign="top">Set element name. Set Struts Action field to populate with selected list keys.</td> </tr> diff --git a/content/tag-developers/tag-syntax.html b/content/tag-developers/tag-syntax.html index 5b7c991..9d809dc 100644 --- a/content/tag-developers/tag-syntax.html +++ b/content/tag-developers/tag-syntax.html @@ -127,86 +127,105 @@ <section class="col-md-12"> <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/tag-developers/tag-syntax.md" title="Edit this page on GitHub">Edit on GitHub</a> - <h1 id="tag-syntax">Tag Syntax</h1> + <h1 class="no_toc" id="tag-syntax">Tag Syntax</h1> -<p>The tags are designed to display dynamic data. To create a input field that displays the property “postalCode”, we’d pass the String “postalCode” to the textfield tag.</p> +<ul id="markdown-toc"> + <li><a href="#creating-a-dynamic-input-field" id="markdown-toc-creating-a-dynamic-input-field">Creating a dynamic input field</a> <ul> + <li><a href="#using-an-expression-to-set-the-label" id="markdown-toc-using-an-expression-to-set-the-label">Using an expression to set the label</a></li> + </ul> + </li> + <li><a href="#non-string-attributes" id="markdown-toc-non-string-attributes">Non-String Attributes</a> <ul> + <li><a href="#evaluating-booleans" id="markdown-toc-evaluating-booleans">Evaluating booleans</a></li> + <li><a href="#evaluating-booleans-verbose" id="markdown-toc-evaluating-booleans-verbose">Evaluating booleans (verbose)</a></li> + <li><a href="#evaluating-booleans-with-property" id="markdown-toc-evaluating-booleans-with-property">Evaluating booleans (with property)</a></li> + <li><a href="#evaluating-booleans-verbose-with-property" id="markdown-toc-evaluating-booleans-verbose-with-property">Evaluating booleans (verbose with property)</a></li> + </ul> + </li> + <li><a href="#value-is-an-object" id="markdown-toc-value-is-an-object">value is an Object!</a></li> + <li><a href="#probably-wrong" id="markdown-toc-probably-wrong">Probably wrong!</a></li> + <li><a href="#passing-a-literal-value-the-right-way" id="markdown-toc-passing-a-literal-value-the-right-way">Passing a literal value the right way</a></li> + <li><a href="#expression-language-notations" id="markdown-toc-expression-language-notations">Expression Language Notations</a></li> + <li><a href="#disallowed-property-names" id="markdown-toc-disallowed-property-names">Disallowed property names</a></li> +</ul> -<p><strong>Creating a dynamic input field</strong></p> +<p>The tags are designed to display dynamic data. To create a input field that displays the property “postalCode”, +we’d pass the String “postalCode” to the textfield tag.</p> -<pre><code class="language-jsp"> -<s:textfield name="postalCode"/> +<h2 id="creating-a-dynamic-input-field">Creating a dynamic input field</h2> +<pre><code class="language-jsp"><s:textfield name="postalCode"/> </code></pre> -<p>If there is a “postalCode” property on the value stack, its value will be set to the input field. When the field is submitted back to the framework, the value of the control will be set back to the “postalCode” property.</p> - -<p>Sometimes, we want to pass the dynamic data to a tag. For example, we might want to display a label with the input field, and we might want to obtain the label from the application’s messages resources. Accordingly, the framework will parse expressions found in the tag attributes, so that we can merge dynamic data into the tag attributes at runtime. The expression escape sequence is “%{ … }”. Any text embedded in the escape sequence is evalulated as an expression.</p> +<p>If there is a “postalCode” property on the value stack, its value will be set to the input field. When the field is +submitted back to the framework, the value of the control will be set back to the “postalCode” property.</p> -<p><strong>Using an expression to set the label</strong></p> +<p>Sometimes, we want to pass the dynamic data to a tag. For example, we might want to display a label with the input +field, and we might want to obtain the label from the application’s messages resources. Accordingly, the framework will +parse expressions found in the tag attributes, so that we can merge dynamic data into the tag attributes at runtime. +The expression escape sequence is <code class="highlighter-rouge">%{ ... }</code>. Any text embedded in the escape sequence is evalulated as an expression.</p> -<pre><code class="language-jsp"> -<s:textfield key="postalCode.label" name="postalCode"/> +<h3 id="using-an-expression-to-set-the-label">Using an expression to set the label</h3> +<pre><code class="language-jsp"><s:textfield key="postalCode.label" name="postalCode"/> </code></pre> -<p>The expression language (<a href="ognl.html">OGNL</a>) lets us call methods and evaluate properties. The method <code class="highlighter-rouge">getText</code> is provided by ActionSupport, which is the base class for most Actions. Since the Action is on the stack, we can call any of its methods from an expression, including <code class="highlighter-rouge">getText</code>.</p> +<p>The expression language (<a href="ognl">OGNL</a>) lets us call methods and evaluate properties. The method <code class="highlighter-rouge">getText</code> is provided +by <code class="highlighter-rouge">ActionSupport</code>, which is the base class for most Actions. Since the Action is on the stack, we can call any of its +methods from an expression, including <code class="highlighter-rouge">getText</code>.</p> <h2 id="non-string-attributes">Non-String Attributes</h2> -<p>The HTTP protocol is text-based, but some tags have non-String attribute types, like <code class="highlighter-rouge">bool</code> or <code class="highlighter-rouge">int</code>. To make using non-String attributes intuitative, the framework evaulates <strong>all</strong> non-String attributes as an expression. In this case, you do not need to use the escape notation. (But, if you do anyway , the framework will just strip it off.)</p> +<p>The HTTP protocol is text-based, but some tags have non-String attribute types, like <code class="highlighter-rouge">bool</code> or <code class="highlighter-rouge">int</code>. To make using +non-String attributes intuitative, the framework evaulates <strong>all</strong> non-String attributes as an expression. +In this case, you do not need to use the escape notation. (But, if you do anyway , the framework will just strip it off.)</p> -<p><strong>Evaluating booleans</strong></p> - -<pre><code class="language-jsp"> -<s:select key="state.label" name="state" multiple="true"/> +<h3 id="evaluating-booleans">Evaluating booleans</h3> +<pre><code class="language-jsp"><s:select key="state.label" name="state" multiple="true"/> </code></pre> -<p>Since the attribute <code class="highlighter-rouge">multiple</code> maps to a boolean property, the framework does not interpret the value as a String. The value is evaluated as an expression and automtically converted to a boolean.</p> +<p>Since the attribute <code class="highlighter-rouge">multiple</code> maps to a boolean property, the framework does not interpret the value as a String. +The value is evaluated as an expression and automtically converted to a boolean.</p> <p>Since it’s easy to forget which attributes are String and which are non-String, you can still use the escape notation.</p> -<p><strong>Evaluating booleans (verbose)</strong></p> - -<pre><code class="language-jsp"> -<s:select key="state.label" name="state" multiple="%{true}"/> +<h3 id="evaluating-booleans-verbose">Evaluating booleans (verbose)</h3> +<pre><code class="language-jsp"><s:select key="state.label" name="state" multiple="%{true}"/> </code></pre> -<p><strong>Evaluating booleans (with property)</strong></p> - -<pre><code class="language-jsp"> -<s:select key="state.label" name="state" multiple="allowMultiple"/> +<h3 id="evaluating-booleans-with-property">Evaluating booleans (with property)</h3> +<pre><code class="language-jsp"><s:select key="state.label" name="state" multiple="allowMultiple"/> </code></pre> -<p><strong>Evaluating booleans (verbose with property)</strong></p> - -<pre><code class="language-jsp"> -<s:select key="state.label" name="state" multiple="%{allowMultiple}"/> +<h3 id="evaluating-booleans-verbose-with-property">Evaluating booleans (verbose with property)</h3> +<pre><code class="language-jsp"><s:select key="state.label" name="state" multiple="%{allowMultiple}"/> </code></pre> <h2 id="value-is-an-object">value is an Object!</h2> -<p>Most often, the <code class="highlighter-rouge">value</code> attribute is set automatically, since <code class="highlighter-rouge">name</code> attribute usually tells the framework which property to call to set the <code class="highlighter-rouge">value</code>. But, if there is a reason to set the <code class="highlighter-rouge">value</code> directly, be advised that <code class="highlighter-rouge">value</code><strong>is an Object</strong><strong><em>NOT</em> **</strong>a String**.</p> +<p>Most often, the <code class="highlighter-rouge">value</code> attribute is set automatically, since <code class="highlighter-rouge">name</code> attribute usually tells the framework which +property to call to set the <code class="highlighter-rouge">value</code>. But, if there is a reason to set the <code class="highlighter-rouge">value</code> directly, be advised that <code class="highlighter-rouge">value</code> +<strong>is an Object</strong><strong><em>NOT</em> **</strong>a String**.</p> -<p>(!) Since <code class="highlighter-rouge">value</code> is not a String, whatever is passed to <code class="highlighter-rouge">value</code> is evaluated as an expression - <strong>NOT</strong> a String literal.</p> +<blockquote> + <p>NOTE: Since <code class="highlighter-rouge">value</code> is not a String, whatever is passed to <code class="highlighter-rouge">value</code> is evaluated as an expression - <strong>NOT</strong> a String literal.</p> +</blockquote> -<p><strong>Probably wrong!</strong></p> - -<pre><code class="language-jsp"> -<s:textfield key="state.label" name="state" value="ca"/> +<h2 id="probably-wrong">Probably wrong!</h2> +<pre><code class="language-jsp"><s:textfield key="state.label" name="state" value="ca"/> </code></pre> -<p>If a <code class="highlighter-rouge">textfield</code> is passed the value attribute <code class="highlighter-rouge">"ca"</code>, the framework will look for a property named <code class="highlighter-rouge">getCa</code>. Generally, this is not what we mean. What we mean to do is pass a literal String. In the expression language, literals are placed within quotes</p> - -<p><strong>Passing a literal value the right way</strong></p> +<p>If a <code class="highlighter-rouge">textfield</code> is passed the value attribute <code class="highlighter-rouge">ca</code>, the framework will look for a property named <code class="highlighter-rouge">getCa</code>. Generally, +this is not what we mean. What we mean to do is pass a literal String. In the expression language, literals are placed +within quotes</p> -<pre><code class="language-jsp"> -<s:textfield key="state.label" name="state" value="%{'ca'}" /> +<h2 id="passing-a-literal-value-the-right-way">Passing a literal value the right way</h2> +<pre><code class="language-jsp"><s:textfield key="state.label" name="state" value="%{'ca'}" /> </code></pre> <p>Another approach would be to use the idiom <code class="highlighter-rouge">value="'ca'"</code>, but, in this case, using the expression notation is recommended.</p> @@ -214,79 +233,56 @@ <p>Boiled down, the tag attributes are evaluated using three rules.</p> <ol> - <li> - <p>All <em>String</em> attribute types are <em>parsed</em> for the “%{ … }” notation.</p> - </li> - <li> - <p>All <em>non-String</em> attribute types are <strong>not</strong> parsed, but evaluated directly as an expression</p> - </li> - <li> - <p>The exception to rule #2 is that if the <em>non-String</em> attribute uses the escape notion “%{}”, the notation is ignored as redundant, and the content evaluated.</p> - </li> + <li>All <em>String</em> attribute types are <em>parsed</em> for the <code class="highlighter-rouge">%{ ... }</code> notation.</li> + <li>All <em>non-String</em> attribute types are <strong>not</strong> parsed, but evaluated directly as an expression</li> + <li>The exception to rule #2 is that if the <em>non-String</em> attribute uses the escape notion <code class="highlighter-rouge">%{}</code>, the notation is ignored + as redundant, and the content evaluated.</li> </ol> -<p>Please remember about <em>altSyntax</em> option that can change when value is evaluated as an expression - <em>Alt Syntax</em></p> +<p>Please remember about <em>altSyntax</em> option that can change when value is evaluated as an expression - <a href="alt-syntax">Alt Syntax</a></p> + +<h2 id="expression-language-notations">Expression Language Notations</h2> <table> + <thead> + <tr> + <th>Username: <code class="highlighter-rouge">${user.username}</code></th> + <th>A JavaBean object in a standard context in Freemarker, Velocity, or JSTL EL (Not OGNL).</th> + </tr> + </thead> <tbody> <tr> + <td><code class="highlighter-rouge"><s:textfield name="username"/></code></td> + <td>A username property on the Value Stack.</td> + </tr> + <tr> + <td><code class="highlighter-rouge"><s:url id="es" action="Hello"><s:param name="request_locale">es</s:param></s:url><s:a href="%{es}">Espanol</s:a></code></td> + <td>Another way to refer to a property placed on the Value Stack.</td> + </tr> + <tr> + <td><code class="highlighter-rouge"><s:property value="#session.user.username" /><s:select label="FooBar" name="foo" list="#{'username':'trillian', 'username':'zaphod'}" /></code></td> + <td>A static Map, as in <code class="highlighter-rouge">put("username","trillian")</code>.</td> </tr> </tbody> </table> -<h2 id="expression-language-notations">Expression Language Notations</h2> - -<p>|<p>Username: ${user.username}</p>| A JavaBean object in a standard context in Freemarker, Velocity, or JSTL EL (Not OGNL). | -|—————————————–|——————————————————————————————| -|<s:textfield name="username"></s:textfield>| A username property on the Value Stack. | -|<s:url id="es" action="Hello">\</s:url></p> -<s:param name="request_locale">\ - es\ - </s:param> -<p>\ -</s:url>\</p> -<s:a href="%{es}">Espanol</s:a> -<p>| Another way to refer to a property placed on the Value Stack. | -|<s:property\ - value=”#session.user.username” />| The username property of the User object in the Session context. | -|<s:select\ - label=”FooBar” name=”foo”\ - list=”#{‘username’:’trillian’,\ - ‘username’:’zaphod’}” />| A static Map, as in put(“username”,”trillian”). |</p> - <h2 id="disallowed-property-names">Disallowed property names</h2> <p>The following names of property are disallowed:</p> <ul> - <li> - <p>parameters</p> - </li> - <li> - <p>application</p> - </li> - <li> - <p>session</p> - </li> - <li> - <p>struts</p> - </li> - <li> - <p>request</p> - </li> - <li> - <p>servletRequest</p> - </li> - <li> - <p>servletResponse</p> - </li> + <li>parameters</li> + <li>application</li> + <li>session</li> + <li>struts</li> + <li>request</li> + <li>servletRequest</li> + <li>servletResponse</li> </ul> <p>The below code will not work:</p> -<pre><code class="language-jsp"> -<s:iterator value="parameters"/> - +<pre><code class="language-jsp"><s:iterator value="parameters"/> </code></pre> <div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code>