Modified: websites/production/struts/content/docs/convention-plugin.html ============================================================================== --- websites/production/struts/content/docs/convention-plugin.html (original) +++ websites/production/struts/content/docs/convention-plugin.html Wed Dec 31 13:40:50 2014 @@ -138,12 +138,12 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><style type="text/css">/*<![CDATA[*/ -div.rbtoc1405758713322 {padding: 0px;} -div.rbtoc1405758713322 ul {list-style: none;margin-left: 0px;} -div.rbtoc1405758713322 li {margin-left: 0px;padding-left: 0px;} + <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/ +div.rbtoc1420032940249 {padding: 0px;} +div.rbtoc1420032940249 ul {list-style: none;margin-left: 0px;} +div.rbtoc1420032940249 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style><div class="toc-macro rbtoc1405758713322"> +/*]]>*/</style></p><div class="toc-macro rbtoc1420032940249"> <ul class="toc-indentation"><li><span class="TOCOutline">1</span> <a shape="rect" href="#ConventionPlugin-Introduction">Introduction</a></li><li><span class="TOCOutline">2</span> <a shape="rect" href="#ConventionPlugin-Setup">Setup</a></li><li><span class="TOCOutline">3</span> <a shape="rect" href="#ConventionPlugin-ConvertingaCodebehindbasedapplicationtoConvention">Converting a Codebehind based application to Convention</a></li><li><span class="TOCOutline">4</span> <a shape="rect" href="#ConventionPlugin-Helloworld">Hello world</a></li><li><span class="TOCOutline">5</span> <a shape="rect" href="#ConventionPlugin-Codebehindhelloworld">Code behind hello world</a></li><li><span class="TOCOutline">6</span> <a shape="rect" href="#ConventionPlugin-Resultsandresultcodes">Results and result codes</a></li><li><span class="TOCOutline">7</span> <a shape="rect" href="#ConventionPlugin-Chaining">Chaining</a></li><li><span class="TOCOutline">8</span> <a shape="rect" href="#ConventionPlugin-XWork packages">XWork packages</a></li><li><span class="TOCOutline">9</span> <a shape="rect" href="#ConventionPlugin-Annotationreference">Annotation reference</a> <ul class="toc-indentation"><li><span class="TOCOutline">9.1</span> <a shape="rect" href="#ConventionPlugin-Actionannotation">Action annotation</a> <ul class="toc-indentation"><li><span class="TOCOutline">9.1.1</span> <a shape="rect" href="#ConventionPlugin-Applying@Actionand@Actionsattheclasslevel">Applying @Action and @Actions at the class level</a></li></ul> @@ -151,111 +151,45 @@ div.rbtoc1405758713322 li {margin-left: </li><li><span class="TOCOutline">10</span> <a shape="rect" href="#ConventionPlugin-Actionsinjarfiles">Actions in jar files</a></li><li><span class="TOCOutline">11</span> <a shape="rect" href="#ConventionPlugin-Automaticconfigurationreloading">Automatic configuration reloading</a></li><li><span class="TOCOutline">12</span> <a shape="rect" href="#ConventionPlugin-JBoss">JBoss</a></li><li><span class="TOCOutline">13</span> <a shape="rect" href="#ConventionPlugin-Jetty(embedded)">Jetty (embedded)</a></li><li><span class="TOCOutline">14</span> <a shape="rect" href="#ConventionPlugin-Troubleshooting">Troubleshooting</a> <ul class="toc-indentation"><li><span class="TOCOutline">14.1</span> <a shape="rect" href="#ConventionPlugin-Tips">Tips</a></li><li><span class="TOCOutline">14.2</span> <a shape="rect" href="#ConventionPlugin-CommonErrors">Common Errors</a></li></ul> </li><li><span class="TOCOutline">15</span> <a shape="rect" href="#ConventionPlugin-Overwritingpluginclasses">Overwriting plugin classes</a></li><li><span class="TOCOutline">16</span> <a shape="rect" href="#ConventionPlugin-Configurationreference">Configuration reference</a></li></ul> -</div> - -<h1 id="ConventionPlugin-Introduction">Introduction</h1> - -<p>The Convention Plugin is bundled with Struts since 2.1 and replaces the <a shape="rect" href="codebehind-plugin.html">Codebehind Plugin</a> and Zero Config plugins. It provides the following features:</p> - -<ul><li>Action location by package naming conventions</li><li>Result (JSP, FreeMarker, etc) location by naming conventions</li><li>Class name to URL naming convention</li><li>Package name to namespace convention</li><li>SEO compliant URLs (i.e. my-action rather than MyAction)</li><li>Action name overrides using annotations</li><li>Interceptor overrides using annotations</li><li>Namespace overrides using annotations</li><li>XWork package overrides using annotations</li><li>Default action and result handling (i.e. /products will try com.example.actions.Products as well as com.example.actions.products.Index)</li></ul> - - -<p>The Convention Plugin should require no configuration to use. Many of the conventions can be controlled using configuration properties and many of the classes can be extended or overridden.</p> - -<h1 id="ConventionPlugin-Setup">Setup</h1> - -<p>In order to use the Convention plugin, you first need to add the JAR file to the <code>WEB-INF/lib</code> directory of your application or include the dependency in your project's Maven POM file.</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[ -<dependency> +</div><h1 id="ConventionPlugin-Introduction">Introduction</h1><p>The Convention Plugin is bundled with Struts since 2.1 and replaces the <a shape="rect" href="codebehind-plugin.html">Codebehind Plugin</a> and Zero Config plugins. It provides the following features:</p><ul><li>Action location by package naming conventions</li><li>Result (JSP, FreeMarker, etc) location by naming conventions</li><li>Class name to URL naming convention</li><li>Package name to namespace convention</li><li>SEO compliant URLs (i.e. my-action rather than MyAction)</li><li>Action name overrides using annotations</li><li>Interceptor overrides using annotations</li><li>Namespace overrides using annotations</li><li>XWork package overrides using annotations</li><li>Default action and result handling (i.e. /products will try com.example.actions.Products as well as com.example.actions.products.Index)</li></ul><p>The Convention Plugin should require no configuration to use. Many of the conventions can be controlled using configuration properties and many of the classes can be extended or overridden.</p><h1 id="ConventionPlugin-Setup">Setup</h1><p>In order to use the Convention plugin, you first need to add the JAR file to the <code>WEB-INF/lib</code> directory of your application or include the dependency in your project's Maven POM file.</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[<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> <version>X.X.X</version> </dependency> ]]></script> -</div></div> - -<p>Where X.X.X is the current version of Struts 2. Please remember that the Convention Plugin is available from version 2.1.6.</p> - -<h1 id="ConventionPlugin-ConvertingaCodebehindbasedapplicationtoConvention">Converting a Codebehind based application to Convention</h1> - -<p>See <a shape="rect" href="converting-application-from-codebehind-to-convention-plugin.html">this page</a> for the required changes and tips.</p> - -<p>If you are using REST with the Convention plugin, make sure you set these constants in 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[ -<constant name="struts.convention.action.suffix" value="Controller"/> +</div></div><p>Where X.X.X is the current version of Struts 2. Please remember that the Convention Plugin is available from version 2.1.6.</p><h1 id="ConventionPlugin-ConvertingaCodebehindbasedapplicationtoConvention">Converting a Codebehind based application to Convention</h1><p>See <a shape="rect" href="converting-application-from-codebehind-to-convention-plugin.html">this page</a> for the required changes and tips.</p><p>If you are using REST with the Convention plugin, make sure you set these constants in 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[<constant name="struts.convention.action.suffix" value="Controller"/> <constant name="struts.convention.action.mapAllMatches" value="true"/> <constant name="struts.convention.default.parent.package" value="rest-default"/> ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Helloworld">Hello world</h1> - -<p>Now that the Convention plugin has been added to your application, let's start with a very simple example. This example will use an actionless result that is identified by the URL. By default, the Convention plugin assumes that all of the results are stored in <strong>WEB-INF/content</strong>. This can be changed by setting the property <code>struts.convention.result.path</code> in the Struts properties file to the new location. Don't worry about trailing slashes, the Convention plugin handles this for you. Here is our hello world JSP:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: html; gutter: false" type="syntaxhighlighter"><![CDATA[ -<html> +</div></div><h1 id="ConventionPlugin-Helloworld">Hello world</h1><p>Now that the Convention plugin has been added to your application, let's start with a very simple example. This example will use an actionless result that is identified by the URL. By default, the Convention plugin assumes that all of the results are stored in <strong>WEB-INF/content</strong>. This can be changed by setting the property <code>struts.convention.result.path</code> in the Struts properties file to the new location. Don't worry about trailing slashes, the Convention plugin handles this for you. Here is our hello world JSP:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: html; gutter: false" type="syntaxhighlighter"><![CDATA[<html> <body> Hello world! </body> </html> ]]></script> -</div></div> - -<p>If you start Tomcat (or whichever J2EE container you are using) and type in <a shape="rect" class="external-link" href="http://localhost:8080/hello-world" rel="nofollow">http://localhost:8080/hello-world</a> into your browser you should get this result:</p> - -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -Hello world! +</div></div><p>If you start Tomcat (or whichever J2EE container you are using) and type in <a shape="rect" class="external-link" href="http://localhost:8080/hello-world" rel="nofollow">http://localhost:8080/hello-world</a> (assuming that your context path is "<code>/</code>", ie. starting application from Eclipse) into your browser you should get this result:</p><div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[Hello world! ]]></script> -</div></div> - -<p>This illustrates that the Convention plugin will find results even when no action exists and it is all based on the URL passed to Struts.</p> - -<h1 id="ConventionPlugin-Codebehindhelloworld">Code behind hello world</h1> - -<p>Let's expand on this example and add a code behind class. In order to do this we need to ensure that the Convention plugin is able to find our action classes. By default, the Convention plugin will find all action classes that implement <code>com.opensymphony.xwork2.Action</code> or whose name ends with the word <strong>Action</strong> in specific packages.</p> - -<p>These packages are located by the Convention plugin using a search methodology. First the Convention plugin finds packages named <code>struts</code>, <code>struts2</code>, <code>action</code> or <code>actions</code>. Any packages that match those names are considered the root packages for the Convention plugin. Next, the plugin looks at all of the classes in those packages as well as sub-packages and determines if the classes implement <code>com.opensymphony.xwork2.Action</code> or if their name ends with <strong>Action</strong> (i.e. FooAction). Here's an example of a few classes that the Convention plugin will find:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Classes</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -com.example.actions.MainAction +</div></div><p>This illustrates that the Convention plugin will find results even when no action exists and it is all based on the URL passed to Struts.</p><h1 id="ConventionPlugin-Codebehindhelloworld">Code behind hello world</h1><p>Let's expand on this example and add a code behind class. In order to do this we need to ensure that the Convention plugin is able to find our action classes. By default, the Convention plugin will find all action classes that implement <code>com.opensymphony.xwork2.Action</code> or whose name ends with the word <strong>Action</strong> in specific packages.</p><p>These packages are located by the Convention plugin using a search methodology. First the Convention plugin finds packages named <code>struts</code>, <code>struts2</code>, <code>action</code> or <code>actions</code>. Any packages that match those names are considered the root packages for the Convention plugin. Next, the plugin looks at all of the classes in those packages as well as sub-packag es and determines if the classes implement <code>com.opensymphony.xwork2.Action</code> or if their name ends with <strong>Action</strong> (i.e. FooAction). Here's an example of a few classes that the Convention plugin will find:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Classes</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[com.example.actions.MainAction com.example.actions.products.Display (implements com.opensymphony.xwork2.Action) com.example.struts.company.details.ShowCompanyDetailsAction ]]></script> -</div></div> - -<p>Each of the action classes that the plugin finds will be configured to respond to specific URLs. The URL is based on the package name that the class is defined in and the class name itself. First the plugin determines the namespace of the URL using the package names between the root package and the package the class is defined in. For our examples above, the namespaces would be:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Namespaces</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -com.example.actions.MainAction -> / +</div></div><p>Each of the action classes that the plugin finds will be configured to respond to specific URLs. The URL is based on the package name that the class is defined in and the class name itself. First the plugin determines the namespace of the URL using the package names between the root package and the package the class is defined in. For our examples above, the namespaces would be:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Namespaces</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[com.example.actions.MainAction -> / com.example.actions.products.Display -> /products com.example.struts.company.details.ShowCompanyDetailsAction -> /company/details ]]></script> -</div></div> - -<p>Next, the plugin determines the URL of the resource using the class name. It first removes the word <strong>Action</strong> from the end of the class name and then converts camel case names to dashes. In our example the full URLs would be:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Full URLs</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -com.example.actions.MainAction -> /main +</div></div><p>Next, the plugin determines the URL of the resource using the class name. It first removes the word <strong>Action</strong> from the end of the class name and then converts camel case names to dashes. In our example the full URLs would be:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Full URLs</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[com.example.actions.MainAction -> /main com.example.actions.products.Display -> /products/display com.example.struts.company.details.ShowCompanyDetailsAction -> /company/details/show-company-details ]]></script> -</div></div> - -<p>You can tell the Convention plugin to ignore certain packages using the property <code>struts.convention.exclude.packages</code>. You can also tell the plugin to use different strings to locate root packages using the property <code>struts.convention.package.locators</code>. Finally, you can tell the plugin to search specific root packages using the property <code>struts.convention.action.packages</code>.</p> - -<p>Here is our code behind action class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>You can tell the Convention plugin to ignore certain packages using the property <code>struts.convention.exclude.packages</code>. You can also tell the plugin to use different strings to locate root packages using the property <code>struts.convention.package.locators</code>. Finally, you can tell the plugin to search specific root packages using the property <code>struts.convention.action.packages</code>.</p><p>Here is our code behind action class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; @@ -272,37 +206,24 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>If you compile this class and place it into your application in the WEB-INF/classes, the Convention plugin will find the class and map the URL <strong>/hello-world</strong> to it. Next, we need to update our JSP to print out the message we setup in the action class. Here is the new JSP:</p> - -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<html> +</div></div><p>If you compile this class and place it into your application in the WEB-INF/classes, the Convention plugin will find the class and map the URL <strong>/hello-world</strong> to it. Next, we need to update our JSP to print out the message we setup in the action class. Here is the new JSP:</p><div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<html> <body> The message is ${message} </body> </html> ]]></script> -</div></div> - -<p>If start up the application server and open up <a shape="rect" class="external-link" href="http://localhost:8080/hello-world" rel="nofollow">http://localhost:8080/hello-world</a> in our browser, we should get this result:</p> - -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Result</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -The message is Hello World! +</div></div> <div class="aui-message warning shadowed information-macro"> + <span class="aui-icon icon-warning">Icon</span> + <div class="message-content"> + <p>Please notice that the expression <code>${message</code><span>}</span> will work without adding JSP directive <code>isELIgnored="false"</code>.</p> + </div> + </div> +<p> </p><p>If start up the application server and open up <a shape="rect" class="external-link" href="http://localhost:8080/hello-world" rel="nofollow">http://localhost:8080/hello-world</a> in our browser, we should get this result:</p><div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Result</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[The message is Hello World! ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Resultsandresultcodes">Results and result codes</h1> - -<p>The Convention Plugin will pre-configure all of you action classes when Struts is started. By default, this configuration will also contain results for any JSPs that it can find within the application. The JSPs have an additional feature that allows different JSPs to be used based on the result code of the action. Since action methods return Strings and these Strings are traditionally used to locate results for the action, the Convention plugin allows you to define different results based on the result code.</p> - -<p>Building on our example from above, let's say we want to provide a different result if the result code from our action is the String <code>zero</code> rather than <code>success</code>. First, we update the action class to return different result codes:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><h1 id="ConventionPlugin-Resultsandresultcodes">Results and result codes</h1><p>The Convention Plugin will pre-configure all of you action classes when Struts is started. By default, this configuration will also contain results for any JSPs that it can find within the application. The JSPs have an additional feature that allows different JSPs to be used based on the result code of the action. Since action methods return Strings and these Strings are traditionally used to locate results for the action, the Convention plugin allows you to define different results based on the result code.</p><p>Building on our example from above, let's say we want to provide a different result if the result code from our action is the String <code>zero</code> rather than <code>success</code>. First, we update the action class to return different result codes:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"> <b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; @@ -324,36 +245,15 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>Next, we add a new JSP to the application named <code>WEB-INF/content/hello-world-zero.jsp</code>. Notice that the first part of the file name is the same as the URL of the action and the last part of the name is the result code. This is the convention that the plugin uses to determine which results to render. Here is our new JSP:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<html> +</div></div><p>Next, we add a new JSP to the application named <code>WEB-INF/content/hello-world-zero.jsp</code>. Notice that the first part of the file name is the same as the URL of the action and the last part of the name is the result code. This is the convention that the plugin uses to determine which results to render. Here is our new JSP:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>WEB-INF/content/hello-world.jsp</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<html> <body> The error message is ${message} </body> </html> ]]></script> -</div></div> - -<p>Now, if you compile the action and restart the application, based on the current time, you'll either see the result from <code>WEB-INF/content/hello-world.jsp</code> or <code>WEB-INF/content/hello-world-zero.jsp</code>.</p> - - - -<p>The result type is based on the extension of the file. The supported extensions are: jsp,ftl,vm,html,html. Examples of Action and Result to Template mapping:</p> - -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> URL </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Result </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> File that could match </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Result Type </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> /hello </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> success </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/hello.jsp </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Dispatcher </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> /hello </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> success </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/hello-success.htm </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Dispatcher </p></td></tr><tr>< td colspan="1" rowspan="1" class="confluenceTd"><p> /hello </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> success </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/hello.ftl </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> FreeMarker </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> /hello-world </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> input </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/hello-world-input.vm </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Velocity </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> /test1/test2/hello </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> error </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/test/test2/hello-error.html </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Dispatcher </p></td></tr></tbody></table></div> - - -<h1 id="ConventionPlugin-Chaining">Chaining</h1> - -<p>If one action returns the name of another action in the same package, they will be chained together, if the first action doesn't have any result defined for that code. In the following example:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>Now, if you compile the action and restart the application, based on the current time, you'll either see the result from <code>WEB-INF/content/hello-world.jsp</code> or <code>WEB-INF/content/hello-world-zero.jsp</code>.</p><p>The result type is based on the extension of the file. The supported extensions are: jsp,ftl,vm,html,html. Examples of Action and Result to Template mapping:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>URL</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Result</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>File that could match</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Result Type</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>/hello</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>success</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/WEB-INF/content/hello.jsp</p></td><td colspan=" 1" rowspan="1" class="confluenceTd"><p>Dispatcher</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>/hello</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>success</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/WEB-INF/content/hello-success.htm</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Dispatcher</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>/hello</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>success</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/WEB-INF/content/hello.ftl</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>FreeMarker</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>/hello-world</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>input</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/WEB-INF/content/hello-world-input.vm</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Velocity</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>/test1/test2/hello</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>error</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/WEB-INF/content/test/test2/hello-error.html</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Dispatcher</p></td></tr></tbody></table></div><h1 id="ConventionPlugin-Chaining">Chaining</h1><p>If one action returns the name of another action in the same package, they will be chained together, if the first action doesn't have any result defined for that code. In the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; @@ -370,41 +270,14 @@ public class HelloAction extends ActionS } } ]]></script> -</div></div> - -<p>The "foo" action will be executed, because no result is found, the Convention plugin tries to find an action named "foo-bar" on the same package where "foo" is defined. If such an action is found, it will be invoked using the "chain" result.</p> - -<h1 id="ConventionPlugin-XWorkpackages">XWork packages</h1> - -<p>Actions are placed on a custom XWork package which prevents conflicts. The name of this package is based on the Java package the action is defined in, the namespace part of the URL for the action and the parent XWork package for the action. The parent XWork package is determined based on the property named <code>struts.convention.default.parent.package</code>(defaults to <code>convention-default</code>), which is a custom XWork package that extends <code>struts-default</code>.</p> - -<p>Therefore the naming for XWork packages used by the Convention plugin are in the form:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>XWork package naming</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<java-package>#<namespace>#<parent-package> +</div></div><p>The "foo" action will be executed, because no result is found, the Convention plugin tries to find an action named "foo-bar" on the same package where "foo" is defined. If such an action is found, it will be invoked using the "chain" result.</p><h1 id="ConventionPlugin-XWorkpackages">XWork packages</h1><p>Actions are placed on a custom XWork package which prevents conflicts. The name of this package is based on the Java package the action is defined in, the namespace part of the URL for the action and the parent XWork package for the action. The parent XWork package is determined based on the property named <code>struts.convention.default.parent.package</code>(defaults to <code>convention-default</code>), which is a custom XWork package that extends <code>struts-default</code>.</p><p>Therefore the naming for XWork packages used by the Convention plugin are in the form:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" st yle="border-bottom-width: 1px;"><b>XWork package naming</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<java-package>#<namespace>#<parent-package> ]]></script> -</div></div> - -<p>Using our example from above, the XWork package for our action would be:</p> - -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>XWork package naming</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -com.example.actions#/#conventionDefault +</div></div><p>Using our example from above, the XWork package for our action would be:</p><div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>XWork package naming</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[com.example.actions#/#conventionDefault ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Annotationreference">Annotation reference</h1> - -<p>The Convention plugin uses a number of different annotations to override the default conventions that are used to map actions to URLs and locate results. In addition, you can modify the parent XWork package that actions are configured with.</p> - -<h2 id="ConventionPlugin-Actionannotation">Action annotation</h2> - -<p>The Convention plugin allows action classes to change the URL that they are mapped to using the <strong>Action</strong> annotation. This annotation can also be used inside the <strong>Actions</strong> annotation to allow multiple URLs to map to a single action class. This annotation must be defined on action methods like this:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><h1 id="ConventionPlugin-Annotationreference">Annotation reference</h1><p>The Convention plugin uses a number of different annotations to override the default conventions that are used to map actions to URLs and locate results. In addition, you can modify the parent XWork package that actions are configured with.</p><h2 id="ConventionPlugin-Actionannotation">Action annotation</h2><p>The Convention plugin allows action classes to change the URL that they are mapped to using the <strong>Action</strong> annotation. This annotation can also be used inside the <strong>Actions</strong> annotation to allow multiple URLs to map to a single action class. This annotation must be defined on action methods like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -416,15 +289,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>Our action class will now map to the URL <code>/different/url</code> rather than <code>/hello-world</code>. If no <code>@Result</code> (see next section) is specified, then the namespace of the action will be used as the path to the result, on our last example it would be <code>/WEB-INF/content/different/url.jsp</code>.</p> - -<p>A single method within an action class can also map to multiple URLs using the <strong>Actions</strong> annotation like this:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>Our action class will now map to the URL <code>/different/url</code> rather than <code>/hello-world</code>. If no <code>@Result</code> (see next section) is specified, then the namespace of the action will be used as the path to the result, on our last example it would be <code>/WEB-INF/content/different/url.jsp</code>.</p><p>A single method within an action class can also map to multiple URLs using the <strong>Actions</strong> annotation like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -440,13 +306,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>Another usage of the <strong>Action</strong> or <strong>Actions</strong> annotation is to define multiple action methods within a single action class, each of which respond to a different URL. Here is an example of multiple action methods:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>Another usage of the <strong>Action</strong> or <strong>Actions</strong> annotation is to define multiple action methods within a single action class, each of which respond to a different URL. Here is an example of multiple action methods:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -466,15 +327,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>The previous example defines a second URL that is not fully qualified. This means that the namespace for the URL is determined using the Java package name rather than the Action annotation.</p> - -<p>Interceptor and interceptor stacks can be specified using the <code>interceptorRefs</code> attribute. The following example applies the <code>validation</code> interceptor and the <code>defaultStack</code> interceptor stack to the action:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>The previous example defines a second URL that is not fully qualified. This means that the namespace for the URL is determined using the Java package name rather than the Action annotation.</p><p>Interceptor and interceptor stacks can be specified using the <code>interceptorRefs</code> attribute. The following example applies the <code>validation</code> interceptor and the <code>defaultStack</code> interceptor stack to the action:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -492,13 +346,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>Parameters can be passed to results using the <strong>params</strong> attribute. The value of this attribute is a string array with an even number of elements in the form {"key0", "value0, "key1", "value1" ... "keyN", "valueN"}. For example:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>Parameters can be passed to results using the <strong>params</strong> attribute. The value of this attribute is a string array with an even number of elements in the form {"key0", "value0, "key1", "value1" ... "keyN", "valueN"}. For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -516,31 +365,14 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>If interceptors are not specified, the default stack is applied.</p> - <div class="aui-message hint shadowed information-macro"> +</div></div><p>If interceptors are not specified, the default stack is applied.</p> <div class="aui-message hint shadowed information-macro"> <span class="aui-icon icon-hint">Icon</span> <div class="message-content"> <p>You can specify className parameter which can be especially useful when Spring Framework is used to instantiate actions.</p> </div> </div> - - - - -<h3 id="ConventionPlugin-Applying@Actionand@Actionsattheclasslevel">Applying @Action and @Actions at the class level</h3> - -<p>There are circumstances when this is desired, like when using <a shape="rect" href="action-configuration.html#ActionConfiguration-DynamicMethodInvocation">Dynamic Method Invocation</a>. If an <code>execute</code> method is defined in the class, then it will be used for the action mapping, otherwise the method to be used will be determined when a request is made (by Dynamic Method Invocation for example)</p> - - -<h2 id="ConventionPlugin-InterceptorRefannotation">InterceptorRef annotation</h2> - -<p>Interceptors can be specified at the method level, using the <strong>Action</strong> annotation or at the class level using the <code>InterceptorRefs</code> annotation. Interceptors specified at the class level will be applied to all actions defined on that class. In the following example:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +<h3 id="ConventionPlugin-Applying@Actionand@Actionsattheclasslevel">Applying @Action and @Actions at the class level</h3><p>There are circumstances when this is desired, like when using <a shape="rect" href="action-configuration.html#ActionConfiguration-DynamicMethodInvocation">Dynamic Method Invocation</a>. If an <code>execute</code> method is defined in the class, then it will be used for the action mapping, otherwise the method to be used will be determined when a request is made (by Dynamic Method Invocation for example)</p><h2 id="ConventionPlugin-InterceptorRefannotation">InterceptorRef annotation</h2><p>Interceptors can be specified at the method level, using the <strong>Action</strong> annotation or at the class level using the <code>InterceptorRefs</code> annotation. Interceptors specified at the class level will be applied to all actions defined on that class. In the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHe ader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -562,27 +394,14 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>The following interceptors will be applied to "action1": <code>interceptor-1</code>, all interceptors from <code>defaultStack</code>, <code>validation</code>.<br clear="none"> -All interceptors from <code>defaultStack</code> will be applied to "action2".</p> - - <div class="aui-message warning shadowed information-macro"> +</div></div><p>The following interceptors will be applied to "action1": <code>interceptor-1</code>, all interceptors from <code>defaultStack</code>, <code>validation</code>.<br clear="none"> All interceptors from <code>defaultStack</code> will be applied to "action2".</p> <div class="aui-message warning shadowed information-macro"> <span class="aui-icon icon-warning">Icon</span> <div class="message-content"> - -<p>If you get errors like "Unable to find interceptor class referenced by ref-name XYZ". This means that the package where Convention is placing your actions, does not extend the package where the interceptor is defined. To fix this problem either 1)Use @ParentPackage annotation(or <code>struts.convention.default.parent.package</code>) passing the name of the package that defines the interceptor, or 2) Create a package in XML that extends the package that defines the interceptor, and use @ParentPackage(or <code>struts.convention.default.parent.package</code>) to point to it.</p> + <p>If you get errors like "Unable to find interceptor class referenced by ref-name XYZ". This means that the package where Convention is placing your actions, does not extend the package where the interceptor is defined. To fix this problem either 1)Use @ParentPackage annotation(or <code>struts.convention.default.parent.package</code>) passing the name of the package that defines the interceptor, or 2) Create a package in XML that extends the package that defines the interceptor, and use @ParentPackage(or <code>struts.convention.default.parent.package</code>) to point to it.</p> </div> </div> - - -<h2 id="ConventionPlugin-Resultannotation">Result annotation</h2> - -<p>The Convention plugin allows action classes to define different results for an action. Results fall into two categories, global and local. Global results are shared across all actions defined within the action class. These results are defined as annotations on the action class. Local results apply only to the action method they are defined on. Here is an example of the different types of result annotations:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +<h2 id="ConventionPlugin-Resultannotation">Result annotation</h2><p>The Convention plugin allows action classes to define different results for an action. Results fall into two categories, global and local. Global results are shared across all actions defined within the action class. These results are defined as annotations on the action class. Local results apply only to the action method they are defined on. Here is an example of the different types of result annotations:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -608,13 +427,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>Parameters can be passed to results using the <strong>params</strong> attribute. The value of this attribute is a string array with an even number of elements in the form {"key0", "value0, "key1", "value1" ... "keyN", "valueN"}. For example:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>Parameters can be passed to results using the <strong>params</strong> attribute. The value of this attribute is a string array with an even number of elements in the form {"key0", "value0, "key1", "value1" ... "keyN", "valueN"}. For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -636,17 +450,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>From 2.1.7 on, global results (defined on the class level) defined using annotations will be inherited. Child classes can override the inherited result(s) by redefining it. Also, results defined at the method level take precedence (overwrite), over results with the same name at the action level.</p> - -<h2 id="ConventionPlugin-Namespaceannotation">Namespace annotation</h2> - -<p>The namespace annotation allows the namespace for action classes to be changed instead of using the convention of the Java package name. This annotation can be placed on an action class or within the package-info.java class that allows annotations to be placed on Java packages. When this annotation is put on an action class, it applies to all actions defined in the class, that are not fully qualified action URLs. When this annotation is place in the package-info.java file, it changes the default namespace for all actions defined in the Java package. Here is an example of the annotation on an action class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorl</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>From 2.1.7 on, global results (defined on the class level) defined using annotations will be inherited. Child classes can override the inherited result(s) by redefining it. Also, results defined at the method level take precedence (overwrite), over results with the same name at the action level.</p><h2 id="ConventionPlugin-Namespaceannotation">Namespace annotation</h2><p>The namespace annotation allows the namespace for action classes to be changed instead of using the convention of the Java package name. This annotation can be placed on an action class or within the package-info.java class that allows annotations to be placed on Java packages. When this annotation is put on an action class, it applies to all actions defined in the class, that are not fully qualified action URLs. When this annotation is place in the package-info.java file, it changes the default namespace for all actions defined in the Java package. Here is an example of the annotation on an action cl ass:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorl</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -665,28 +470,12 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>In this example, the action will respond to two different URLs <code>/different/url</code> and <code>/custom/url</code>.</p> - -<p>Here is an example of using this annotation in the package-info.java file:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com/example/actions/package-info.java</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -@org.apache.struts2.convention.annotation.Namespace("/custom") +</div></div><p>In this example, the action will respond to two different URLs <code>/different/url</code> and <code>/custom/url</code>.</p><p>Here is an example of using this annotation in the package-info.java file:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com/example/actions/package-info.java</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@org.apache.struts2.convention.annotation.Namespace("/custom") package com.example.actions; ]]></script> -</div></div> - -<p>This changes the default namespace for all actions defined in the package <code>com.example.actions</code>. This annotation however doesn't apply to sub-packages.</p> - -<h2 id="ConventionPlugin-ResultPathannotation">ResultPath annotation</h2> - -<p>The ResultPath annotation allows applications to change the location where results are stored. This annotation can be placed on an action class and also in the package-info.java file. Here is an example of using this annotation:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorl</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>This changes the default namespace for all actions defined in the package <code>com.example.actions</code>. This annotation however doesn't apply to sub-packages.</p><h2 id="ConventionPlugin-ResultPathannotation">ResultPath annotation</h2><p>The ResultPath annotation allows applications to change the location where results are stored. This annotation can be placed on an action class and also in the package-info.java file. Here is an example of using this annotation:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorl</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -699,17 +488,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>The result for this class will be located in <code>WEB-INF/jsps</code> rather than the default of <code>WEB-INF/content</code>.</p> - -<h2 id="ConventionPlugin-ParentPackageannotation">ParentPackage annotation</h2> - -<p>The ParentPackage annotation allows applications to define different parent Struts package for specific action classes or Java packages. Here is an example of using the annotation on an action class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.actions; +</div></div><p>The result for this class will be located in <code>WEB-INF/jsps</code> rather than the default of <code>WEB-INF/content</code>.</p><h2 id="ConventionPlugin-ParentPackageannotation">ParentPackage annotation</h2><p>The ParentPackage annotation allows applications to define different parent Struts package for specific action classes or Java packages. Here is an example of using the annotation on an action class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>com.example.actions.HelloWorld</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; @@ -722,17 +502,8 @@ public class HelloWorld extends ActionSu } } ]]></script> -</div></div> - -<p>To apply this annotation to all actions in a package (and subpackages), add it to package-info.java. An alternative to this annotation is to set <code>struts.convention.default.parent.package</code> in XML.</p> - -<h2 id="ConventionPlugin-ExceptionMappingAnnotation">ExceptionMapping Annotation</h2> - -<p>This annotation can be used to define exception mappings to actions. See the <a shape="rect" href="exception-configuration.html">exception mapping documentation</a> for more details. These mappings can be applied to the class level, in which case they will be applied to all actions defined on that class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>ExceptionsActionLevelAction.java</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -@ExceptionMappings({ +</div></div><p>To apply this annotation to all actions in a package (and subpackages), add it to package-info.java. An alternative to this annotation is to set <code>struts.convention.default.parent.package</code> in XML.</p><h2 id="ConventionPlugin-ExceptionMappingAnnotation">ExceptionMapping Annotation</h2><p>This annotation can be used to define exception mappings to actions. See the <a shape="rect" href="exception-configuration.html">exception mapping documentation</a> for more details. These mappings can be applied to the class level, in which case they will be applied to all actions defined on that class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>ExceptionsActionLevelAction.java</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@ExceptionMappings({ @ExceptionMapping(exception = "java.lang.NullPointerException", result = "success", params = {"param1", "val1"}) }) public class ExceptionsActionLevelAction { @@ -742,13 +513,8 @@ public class ExceptionsActionLevelAction } } ]]></script> -</div></div> - -<p>The parameters defined by <code>params</code> are passed to the result. Exception mappings can also be applied to the action level:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -public class ExceptionsMethodLevelAction { +</div></div><p>The parameters defined by <code>params</code> are passed to the result. Exception mappings can also be applied to the action level:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[public class ExceptionsMethodLevelAction { @Action(value = "exception1", exceptionMappings = { @ExceptionMapping(exception = "java.lang.NullPointerException", result = "success", params = {"param1", "val1"}) }) @@ -757,100 +523,44 @@ public class ExceptionsMethodLevelAction } } ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Actionsinjarfiles">Actions in jar files</h1> - -<p>By default the Convention plugin will <strong>not</strong> scan jar files for actions. For a jar to be scanned, its URL needs to match at least one of the regular expressions in <code>struts.convention.action.includeJars</code>. In this example <code>myjar1.jar</code> and <code>myjar2.jar</code> will be scanned:</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[ -<constant name="struts.convention.action.includeJars" value=".*?/myjar1.*?jar(!/)?,.*?/myjar2*?jar(!/)?" +</div></div><h1 id="ConventionPlugin-Actionsinjarfiles">Actions in jar files</h1><p>By default the Convention plugin will <strong>not</strong> scan jar files for actions. For a jar to be scanned, its URL needs to match at least one of the regular expressions in <code>struts.convention.action.includeJars</code>. In this example <code>myjar1.jar</code> and <code>myjar2.jar</code> will be scanned:</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[<constant name="struts.convention.action.includeJars" value=".*?/myjar1.*?jar(!/)?,.*?/myjar2*?jar(!/)?" ]]></script> -</div></div> -<p>Note that <strong>the regular expression will be evaluated against the URL of the jar, and not the file name</strong>, the jar URL can contain a path to the jar file and a trailing "!/".</p> - -<h1 id="ConventionPlugin-Automaticconfigurationreloading">Automatic configuration reloading</h1> - -<p>The Convention plugin can automatically reload configuration changes, made in classes the contain actions, without restarting the container. This is a similar behavior to the automatic xml configuration reloading. To enable this feature, add this to your <code>struts.xml</code> file:</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[ -<constant name="struts.devMode" value="true"/> +</div></div><p>Note that <strong>the regular expression will be evaluated against the URL of the jar, and not the file name</strong>, the jar URL can contain a path to the jar file and a trailing "!/".</p><h1 id="ConventionPlugin-Automaticconfigurationreloading">Automatic configuration reloading</h1><p>The Convention plugin can automatically reload configuration changes, made in classes the contain actions, without restarting the container. This is a similar behavior to the automatic xml configuration reloading. To enable this feature, add this to your <code>struts.xml</code> file:</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[<constant name="struts.devMode" value="true"/> <constant name="struts.convention.classes.reload" value="true" /> ]]></script> -</div></div> - -<p>This feature is experimental and has not been tested on all container, and it is <strong>strongly</strong> advised not to use it in production environments.</p> - -<h1 id="ConventionPlugin-JBoss">JBoss</h1> - -<p>When using this plugin with JBoss, you need to set the following constants:</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[ -<constant name="struts.convention.exclude.parentClassLoader" value="true" /> +</div></div><p>This feature is experimental and has not been tested on all container, and it is <strong>strongly</strong> advised not to use it in production environments.</p><h1 id="ConventionPlugin-JBoss">JBoss</h1><p>When using this plugin with JBoss, you need to set the following constants:</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[<constant name="struts.convention.exclude.parentClassLoader" value="true" /> <constant name="struts.convention.action.fileProtocols" value="jar,vfsfile,vfszip" /> ]]></script> -</div></div> - -<p>You can also check the <a shape="rect" href="jboss-5.html">JBoss 5</a> page for more details.</p> - -<h1 id="ConventionPlugin-Jetty(embedded)">Jetty (embedded)</h1> - -<p>When using this plugin with Jetty in embedded mode, you need to set the following constants:</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[ -<constant name="struts.convention.exclude.parentClassLoader" value="false" /> +</div></div><p>You can also check the <a shape="rect" href="jboss-5.html">JBoss 5</a> page for more details.</p><h1 id="ConventionPlugin-Jetty(embedded)">Jetty (embedded)</h1><p>When using this plugin with Jetty in embedded mode, you need to set the following constants:</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[<constant name="struts.convention.exclude.parentClassLoader" value="false" /> <constant name="struts.convention.action.fileProtocols" value="jar,code-source" /> ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Troubleshooting">Troubleshooting</h1> - - -<h2 id="ConventionPlugin-Tips">Tips</h2> - <div class="aui-message success shadowed information-macro"> +</div></div><h1 id="ConventionPlugin-Troubleshooting">Troubleshooting</h1><h2 id="ConventionPlugin-Tips">Tips</h2> <div class="aui-message success shadowed information-macro"> <p class="title">Namespaces and Results</p> <span class="aui-icon icon-success">Icon</span> <div class="message-content"> - -<p>Make sure the namespace of the action is matched by one of the locators. The rest of the namespace after the locator, will be the namespace of the action, and will be used to find the results. For example, a class called "ViewAction" in the package "my.example.actions.orders" will be mapped to the URL <code>/orders/view.action</code>, and the results must be under <code>/WEB-INF/content/orders</code>, like <code>/WEB-INF/content/orders/view-success.jsp</code>.</p> + <p>Make sure the namespace of the action is matched by one of the locators. The rest of the namespace after the locator, will be the namespace of the action, and will be used to find the results. For example, a class called "ViewAction" in the package "my.example.actions.orders" will be mapped to the URL <code>/orders/view.action</code>, and the results must be under <code>/WEB-INF/content/orders</code>, like <code>/WEB-INF/content/orders/view-success.jsp</code>.</p> </div> </div> - - <div class="aui-message success shadowed information-macro"> <p class="title">Use the Configuration Browser Plugin</p> <span class="aui-icon icon-success">Icon</span> <div class="message-content"> - -<p>Add the <a shape="rect" href="config-browser-plugin.html">Config Browser Plugin</a> plugin to the lib folder or maven dependencies, and then visit: <a shape="rect" class="external-link" href="http://localhost:8080/CONTEXT/config-browser/index.action" rel="nofollow">http://localhost:8080/CONTEXT/config-browser/index.action</a>, to see the current action mappings.</p> + <p>Add the <a shape="rect" href="config-browser-plugin.html">Config Browser Plugin</a> plugin to the lib folder or maven dependencies, and then visit: <a shape="rect" class="external-link" href="http://localhost:8080/CONTEXT/config-browser/index.action" rel="nofollow">http://localhost:8080/CONTEXT/config-browser/index.action</a>, to see the current action mappings.</p> </div> </div> - - <div class="aui-message success shadowed information-macro"> <p class="title">Enable trace or debug mode</p> <span class="aui-icon icon-success">Icon</span> <div class="message-content"> - -<p>The Convention plugin can generate a rather verbose output when set to debug mode for logging. Use "Trace" logging level if you are using the JDK logger. If you are using Log4J, you can do something like:</p> - -<p>log4j.logger.org.apache.struts2.convention=DEBUG</p> + <p>The Convention plugin can generate a rather verbose output when set to debug mode for logging. Use "Trace" logging level if you are using the JDK logger. If you are using Log4J, you can do something like:</p><p>log4j.logger.org.apache.struts2.convention=DEBUG</p> </div> </div> - - -<h2 id="ConventionPlugin-CommonErrors">Common Errors</h2> - -<ol><li>I get an error like "There is no Action mapped for namespace /orders and action name view.". This means that the URL <code>/orders/view.action</code> is not mapping to any action class. Check the namespace and the name of the action.</li><li>I get an error like "No result defined for action my.example.actions.orders.ViewAction and result success". This means that the action was mapped to the right URL, but the Convention plugin was unable to find a <code>success</code> result for it. Check that the result file exists, like <code>/WEB-INF/content/orders/view-success.jsp</code>.</li><li>I get lots of errors like "java.lang.Exception: Could not load org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.class". This happens when <code>struts.convention.action.includeJars</code> is matching jar URLs from external jars.</li><li>I am using a custom interceptor stack and I get an error like "Unable to find interceptor class referenced by ref-name XYZ". This means that the package where Convention is placing your actions, does not extend the package where the interceptor is defined. To fix this problem either 1)Use @ParentPackage annotation(or <code>struts.convention.default.parent.package</code>) passing the name of the package that defines the interceptor, or 2) Create a package in XML that extends the package that defines the interceptor, and use @ParentPackage(or <code>struts.convention.default.parent.package</code>) to point to it.</li></ol> - - -<h1 id="ConventionPlugin-Overwritingpluginclasses">Overwriting plugin classes</h1> - -<p>The Convention plugin can be extended in the same fashion that Struts does. The following beans are defined by default:</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[ -<bean type="org.apache.struts2.convention.ActionConfigBuilder" name="convention" class="org.apache.struts2.convention.PackageBasedActionConfigBuilder"/> +<h2 id="ConventionPlugin-CommonErrors">Common Errors</h2><ol><li>I get an error like "There is no Action mapped for namespace /orders and action name view.". This means that the URL <code>/orders/view.action</code> is not mapping to any action class. Check the namespace and the name of the action.</li><li>I get an error like "No result defined for action my.example.actions.orders.ViewAction and result success". This means that the action was mapped to the right URL, but the Convention plugin was unable to find a <code>success</code> result for it. Check that the result file exists, like <code>/WEB-INF/content/orders/view-success.jsp</code>.</li><li>I get lots of errors like "java.lang.Exception: Could not load org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.class". This happens when <code>struts.convention.action.includeJars</code> is matching jar URLs from external jars.</li><li>I am using a custom interceptor stack and I get an error like "Unable to find interc eptor class referenced by ref-name XYZ". This means that the package where Convention is placing your actions, does not extend the package where the interceptor is defined. To fix this problem either 1)Use @ParentPackage annotation(or <code>struts.convention.default.parent.package</code>) passing the name of the package that defines the interceptor, or 2) Create a package in XML that extends the package that defines the interceptor, and use @ParentPackage(or <code>struts.convention.default.parent.package</code>) to point to it.</li></ol><h1 id="ConventionPlugin-Overwritingpluginclasses">Overwriting plugin classes</h1><p>The Convention plugin can be extended in the same fashion that Struts does. The following beans are defined by default:</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[<bean type="org.apache.struts2.convention.ActionConfigBuilder" name="convention" class="org.apache.struts2.convention.PackageBasedActionConfigBuilder"/> This interface defines how the action configurations for the current web application can be constructed. This must find all actions that are not specifically defined in the struts XML files or any plugins. Furthermore, it must make every effort to locate all action results as well. <bean type="org.apache.struts2.convention.ActionNameBuilder" name="convention" class="org.apache.struts2.convention.SEOActionNameBuilder"/> @@ -871,31 +581,14 @@ This interface defines the conventions t <constant name="struts.convention.interceptorMapBuilder" value="convention"/> <constant name="struts.convention.conventionsService" value="convention"/> ]]></script> -</div></div> - -<p>To plugin a different implementation for one of these classes, implement the interface, define a bean for it, and set the appropriate constant's value with the name of the new bean, for 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[ -<bean type="org.apache.struts2.convention.ActionNameBuilder" name="MyActionNameBuilder" class="example.SultansOfSwingNameBuilder"/> +</div></div><p>To plugin a different implementation for one of these classes, implement the interface, define a bean for it, and set the appropriate constant's value with the name of the new bean, for 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[<bean type="org.apache.struts2.convention.ActionNameBuilder" name="MyActionNameBuilder" class="example.SultansOfSwingNameBuilder"/> <constant name="struts.convention.actionNameBuilder" value="MyActionNameBuilder"/> ]]></script> -</div></div> - -<h1 id="ConventionPlugin-Configurationreference">Configuration reference</h1> - -<p>Add a <strong>constant</strong> element to your struts config file to change the value of a configuration setting, like:</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[ -<constant name="struts.convention.result.path" value="/WEB-INF/mytemplates/"/> +</div></div><h1 id="ConventionPlugin-Configurationreference">Configuration reference</h1><p>Add a <strong>constant</strong> element to your struts config file to change the value of a configuration setting, like:</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[<constant name="struts.convention.result.path" value="/WEB-INF/mytemplates/"/> ]]></script> -</div></div> - -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.alwaysMapExecute </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> true </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Set to false, to prevent Convention from creating a default mapping to "execute" when there are other methods annotated as actions in the class </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.includeJars </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Comma separated list of regular expressions of jar URLs to be scanned. eg. ".<strong>myJar-0\.2.</st rong>,.<strong>thirdparty-0\.1.</strong>" </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.packages </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> An optional list of action packages that this should create configuration for (they don't need to match a locator pattern) </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.result.path </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> /WEB-INF/content/ </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Directory where templates are located </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.result.flatLayout </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> true </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> If set to false, the result can be put in its own directory: resultsRoot/namespac e/actionName/result.extension </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.suffix </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Action </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Suffix used to find actions based on class names </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.disableScanning </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> false </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Scan packages for actions </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.mapAllMatches </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> false </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Create action mappings, even if no @Action is found </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.checkImplementsAction </p></ td><td colspan="1" rowspan="1" class="confluenceTd"><p> true </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Check if an action implements com.opensymphony.xwork2.Action to create an action mapping </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.default.parent.package </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> convention-default </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Default parent package for action mappins </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.name.lowercase </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> true </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Convert action name to lowercase </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.action.name.separator </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> - </p></td><td colspan="1" rowspan="1" cla ss="confluenceTd"><p> Separator used to build the action name, MyAction -> my-action. This character is also used as the separator between the action name and the result in templates, like action-result.jsp </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.package.locators </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> action,actions,struts,struts2 </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Packages whose name end with one of these strings will be scanned for actions </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.package.locators.disable </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> false </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Disable the scanning of packages based on package locators </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> struts.convention.exclude.packages </p></td><td colspan="1" rowspan="1" cla ss="confluenceTd"><p> org.apache.struts.*, <br clear="none" class="atl-forced-newline"> -org.apache.struts2.*, <br clear="none" class="atl-forced-newline"> -org.springframework.web.struts.*, <br clear="none" class="atl-forced-newline"> -org.springframework.web.struts2.*, <br clear="none" class="atl-forced-newline">
[... 6 lines stripped ...]