Repository: struts-site Updated Branches: refs/heads/asf-site 596de5fd8 -> a52b99d12
Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/a52b99d1 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/a52b99d1 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/a52b99d1 Branch: refs/heads/asf-site Commit: a52b99d128721fe283d8ea327f39f83ea09a4c90 Parents: 596de5f Author: jenkins <bui...@apache.org> Authored: Thu Sep 21 12:41:38 2017 +0000 Committer: jenkins <bui...@apache.org> Committed: Thu Sep 21 12:41:38 2017 +0000 ---------------------------------------------------------------------- content/maven-archetypes/index.html | 650 +++---------------- .../struts2-archetype-blank.html | 507 +++++++++++++++ 2 files changed, 603 insertions(+), 554 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/a52b99d1/content/maven-archetypes/index.html ---------------------------------------------------------------------- diff --git a/content/maven-archetypes/index.html b/content/maven-archetypes/index.html index 081c03e..9c7fbfe 100644 --- a/content/maven-archetypes/index.html +++ b/content/maven-archetypes/index.html @@ -126,27 +126,66 @@ <article class="container"> <section class="col-md-12"> <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/maven-archetypes/index.md" title="Edit this page on GitHub">Edit on GitHub</a> - <p>#Struts 2 Maven Archetypes# {#PAGE_108820}</p> - -<p>Struts 2 provides several <a href="http://maven\.apache\.org/">Maven</a>^[http://maven.apache.org/] archetypes that create a starting point for our own applications.</p> - -<p><strong>Contents</strong></p> + <h1 id="struts-2-maven-archetypes">Struts 2 Maven Archetypes</h1> + +<p>Struts 2 provides several <a href="http://maven.apache.org/">Maven</a> archetypes that create a starting point for our own applications.</p> + +<p class="no_toc"><strong>Contents</strong></p> + +<ul id="markdown-toc"> + <li><a href="#struts-2-maven-archetypes" id="markdown-toc-struts-2-maven-archetypes">Struts 2 Maven Archetypes</a> <ul> + <li><a href="#quickstart" id="markdown-toc-quickstart">Quickstart</a></li> + <li><a href="#available-archetypes" id="markdown-toc-available-archetypes">Available Archetypes</a> <ul> + <li><a href="#the-blank-convention-archetype-struts2-archetype-convention" id="markdown-toc-the-blank-convention-archetype-struts2-archetype-convention">The Blank Convention Archetype (struts2-archetype-convention)</a> <ul> + <li><a href="#features" id="markdown-toc-features">Features</a></li> + </ul> + </li> + <li><a href="#the-blank-archetype-struts2-archetype-blank" id="markdown-toc-the-blank-archetype-struts2-archetype-blank">The Blank Archetype (struts2-archetype-blank)</a></li> + <li><a href="#the-starter-archetype-struts2-archetype-starter" id="markdown-toc-the-starter-archetype-struts2-archetype-starter">The Starter Archetype (struts2-archetype-starter)</a> <ul> + <li><a href="#features-1" id="markdown-toc-features-1">Features</a></li> + </ul> + </li> + <li><a href="#the-angularjs-archetype-struts2-archetype-angularjs" id="markdown-toc-the-angularjs-archetype-struts2-archetype-angularjs">The AngularJS Archetype (struts2-archetype-angularjs)</a> <ul> + <li><a href="#features-2" id="markdown-toc-features-2">Features</a></li> + </ul> + </li> + <li><a href="#the-portlet-blank-archetype-struts2-archetype-portlet" id="markdown-toc-the-portlet-blank-archetype-struts2-archetype-portlet">The Portlet Blank Archetype (struts2-archetype-portlet)</a> <ul> + <li><a href="#features-3" id="markdown-toc-features-3">Features</a></li> + </ul> + </li> + <li><a href="#the-portlet-database-archetype-struts2-archetype-dbportlet" id="markdown-toc-the-portlet-database-archetype-struts2-archetype-dbportlet">The Portlet Database Archetype (struts2-archetype-dbportlet)</a> <ul> + <li><a href="#features-4" id="markdown-toc-features-4">Features</a></li> + </ul> + </li> + <li><a href="#the-plugin-archetype-struts2-archetype-plugin" id="markdown-toc-the-plugin-archetype-struts2-archetype-plugin">The Plugin Archetype (struts2-archetype-plugin)</a> <ul> + <li><a href="#features-5" id="markdown-toc-features-5">Features</a></li> + </ul> + </li> + </ul> + </li> + <li><a href="#creating-an-application-using-a-maven-archetype" id="markdown-toc-creating-an-application-using-a-maven-archetype">Creating an Application Using a Maven Archetype</a> <ul> + <li><a href="#staging-repository" id="markdown-toc-staging-repository">Staging repository</a></li> + <li><a href="#archetype-parameters" id="markdown-toc-archetype-parameters">Archetype Parameters</a></li> + </ul> + </li> + <li><a href="#command-quick-reference" id="markdown-toc-command-quick-reference">Command Quick Reference</a></li> + </ul> + </li> +</ul> -<p>###Quickstart###</p> +<h2 id="quickstart">Quickstart</h2> <p>A recommended way to start with Struts2 archetypes is to work with the archetype catalog.</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ - +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ </code></pre> </div> -<p>###Available Archetypes###</p> +<h2 id="available-archetypes">Available Archetypes</h2> -<p>####The Blank Convention Archetype (struts2-archetype-convention)####</p> +<h3 id="the-blank-convention-archetype-struts2-archetype-convention">The Blank Convention Archetype (struts2-archetype-convention)</h3> -<p>#####Features#####</p> +<h4 id="features">Features</h4> <ul> <li> @@ -166,38 +205,33 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-convention \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>####The Blank Archetype (struts2-archetype-blank)####</p> +<h3 id="the-blank-archetype-struts2-archetype-blank">The Blank Archetype (struts2-archetype-blank)</h3> -<p>See the <a href="#PAGE_108834">Struts 2 Blank Archetype</a> page for more information, including some basic Maven information, how to build and run the app, and basic application information.</p> +<p>See the <a href="struts2-archetype-blank.html">Struts 2 Blank Archetype</a> page for more information, including some basic Maven information, how to build and run the app, and basic application information.</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-blank \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - - </code></pre> </div> -<p>####The Starter Archetype (struts2-archetype-starter)####</p> +<h3 id="the-starter-archetype-struts2-archetype-starter">The Starter Archetype (struts2-archetype-starter)</h3> <p>The Starter archetype creates a more featured application using several common technologies used in production applications.</p> -<p>#####Features#####</p> +<h4 id="features-1">Features</h4> <ul> <li> @@ -220,20 +254,18 @@ mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-starter \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>####The AngularJS Archetype (struts2-archetype-angularjs)####</p> +<h3 id="the-angularjs-archetype-struts2-archetype-angularjs">The AngularJS Archetype (struts2-archetype-angularjs)</h3> -<p>#####Features#####</p> +<h4 id="features-2">Features</h4> <ul> <li> @@ -247,22 +279,20 @@ mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-angularjs \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>####The Portlet Blank Archetype (struts2-archetype-portlet)####</p> +<h3 id="the-portlet-blank-archetype-struts2-archetype-portlet">The Portlet Blank Archetype (struts2-archetype-portlet)</h3> <p>The Portlet blank archetype creates a minimally populated JSR 168 portlet.</p> -<p>#####Features#####</p> +<h4 id="features-3">Features</h4> <ul> <li> @@ -275,26 +305,24 @@ mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ <p>Can be deployed as a servlet or portlet application</p> </li> <li> - <p>Can use Maven Jetty plugin to deploy with the pluto-embedded profile (usage âmvn jetty:run -Ppluto-embeddedâ, then access <a href="http://localhost:8080/">http://localhost:8080/</a><artifactId>/pluto/index.jsp)</p> + <p>Can use Maven Jetty plugin to deploy with the pluto-embedded profile (usage âmvn jetty:run -Ppluto-embeddedâ, then access http://localhost:8080/<artifactId>/pluto/index.jsp)</p> </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-portlet \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>####The Portlet Database Archetype (struts2-archetype-dbportlet)####</p> +<h3 id="the-portlet-database-archetype-struts2-archetype-dbportlet">The Portlet Database Archetype (struts2-archetype-dbportlet)</h3> <p>The Portlet database archetype creates a simple JSR 168 portlet that displays the contents of a database table.</p> -<p>#####Features#####</p> +<h4 id="features-4">Features</h4> <ul> <li> @@ -317,20 +345,18 @@ mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myWebApp \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-dbportlet \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>####The Plugin Archetype (struts2-archetype-plugin)####</p> +<h3 id="the-plugin-archetype-struts2-archetype-plugin">The Plugin Archetype (struts2-archetype-plugin)</h3> -<p>#####Features#####</p> +<h4 id="features-5">Features</h4> <ul> <li> @@ -341,103 +367,59 @@ mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \ -DartifactId=myPlugin \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-plugin \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \ -DremoteRepositories=http://struts.apache.org - -</code></pre> -</div> - -<p>###Creating an Application Using a Maven Archetype###</p> - -<p>Run the following command from your new projectâs parent directory. The project will be created in a sub-directory named after the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>artifactId -</code></pre> -</div> -<p>parameter.</p> - -<p>The first two parameters,</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>groupId -</code></pre> -</div> -<p>and</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>artifactId </code></pre> </div> -<p>, should be set according to your needs:</p> -<ul> - <li></li> -</ul> +<h2 id="creating-an-application-using-a-maven-archetype">Creating an Application Using a Maven Archetype</h2> -<div class="highlighter-rouge"><pre class="highlight"><code>groupId -</code></pre> -</div> +<p>Run the following command from your new projectâs parent directory. The project will be created in a sub-directory named after the <code class="highlighter-rouge">artifactId</code> parameter.</p> -<p>This should be the root package of your application, e.g., com.mycompany.myapp.</p> +<p>The first two parameters, <code class="highlighter-rouge">groupId</code> and <code class="highlighter-rouge">artifactId</code>, should be set according to your needs:</p> <ul> - <li></li> + <li> + <p><code class="highlighter-rouge">groupId</code> This should be the root package of your application, e.g., com.mycompany.myapp.</p> + </li> + <li> + <p><code class="highlighter-rouge">artifactId</code> Names the project directory that will be created in the current directory.</p> + </li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code>artifactId -</code></pre> -</div> - -<p>Names the project directory that will be created in the current directory.</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B \ +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B \ -DgroupId=tutorial \ -DartifactId=tutorial \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-blank \ -DarchetypeVersion=<CURRENT_STRUTS_VERSION> -DremoteRepositories=http://struts.apache.org - </code></pre> </div> -<p>where <CURRENT_STRUTS_VERSION> is archetypeâs version you want to use, eg. 2.3.15.1</p> +<p>where <CURRENT_STRUTS_VERSION> is archetypeâs version you want to use, e.g. 2.3.15.1</p> -<p>####Staging repository####</p> +<h3 id="staging-repository">Staging repository</h3> <p>If the above command will fail because of missing archetypes in central repository, you can try to use staging repository like below</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -DarchetypeCatalog=https://repository.apache.org/content/repositories/snapshots/ - +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -DarchetypeCatalog=https://repository.apache.org/content/repositories/snapshots/ </code></pre> </div> <p>or this</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ - +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ </code></pre> </div> -<p>####Archetype Parameters####</p> - -<p>The</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>-B -</code></pre> -</div> -<p>option runs</p> +<h3 id="archetype-parameters">Archetype Parameters</h3> -<div class="highlighter-rouge"><pre class="highlight"><code>archetype:generate -</code></pre> -</div> -<p>in batch mode; it avoids a prompt to confirm our settings.</p> +<p>The <code class="highlighter-rouge">-B</code> option runs <code class="highlighter-rouge">archetype:generate</code> in batch mode; it avoids a prompt to confirm our settings.</p> <table> <thead> @@ -478,7 +460,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ </tbody> </table> -<p>###Command Quick Reference###</p> +<h2 id="command-quick-reference">Command Quick Reference</h2> <p>These commands are used from the directory created by the archetype plugin (the projectâs sub-directory that was created in the previous step).</p> @@ -486,9 +468,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To build</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn install - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn install </code></pre> </div> @@ -496,9 +476,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To create IntelliJ IDEA project files</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn idea:idea - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn idea:idea </code></pre> </div> @@ -506,9 +484,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To create Eclipse project files</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn eclipse:eclipse -Dwtpversion=1.5 - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn eclipse:eclipse -Dwtpversion=1.5 </code></pre> </div> @@ -516,9 +492,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To run test cases</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn test - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn test </code></pre> </div> @@ -526,9 +500,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To clean up (removes generated artifacts)</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn clean - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn clean </code></pre> </div> @@ -536,9 +508,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To package (creates a WAR file)</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn package - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn package </code></pre> </div> @@ -546,9 +516,7 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To grab necessary JAR files etc.</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn initialize - +<div class="highlighter-rouge"><pre class="highlight"><code> mvn initialize </code></pre> </div> @@ -556,435 +524,9 @@ mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ <li>To run it with Jetty</li> </ul> -<div class="highlighter-rouge"><pre class="highlight"><code> - mvn jetty:run - -</code></pre> -</div> - -<p>##Struts 2 Blank Archetype## {#PAGE_108834}</p> - -<p>The Struts 2 Blank Archetype (âblank-archetypeâ) provides a minimal, but complete, Struts 2 application. It demonstrates some of the most basic Struts 2 concepts.</p> - -<p><strong>Features</strong></p> - -<ul> - <li> - <p>XML-based configuration, demonstrates including additional config file</p> - </li> - <li> - <p>Example actions</p> - </li> - <li> - <p>Package-level resource bundle</p> - </li> - <li> - <p>XML-based validation</p> - </li> - <li> - <p>Unit-testing</p> - </li> -</ul> - -<p><strong>Contents</strong></p> - -<p>####Creating Our blank-archetype Project####</p> - -<p>Weâll run the following command from our projectâs parent directory (this is shown using Unix-style commands).</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -$ mvn archetype:generate -B \ - -DgroupId=tutorial \ - -DartifactId=tutorial \ - -DarchetypeGroupId=org.apache.struts \ - -DarchetypeArtifactId=struts2-archetype-blank \ - -DarchetypeVersion=<version> -$ ls -tutorial/ -$ cd tutorial -$ ls -pom.xml src/ - -</code></pre> -</div> - -<p>Depending on the state of your local system you may see Maven downloading various libraries (known as âdownloading the internetâ, which is what it seems Maven does sometimes). Be patient--Maven is basically setting up your required libraries automatically. -<strong><version></strong> - is the version of Struts 2 you want to use and archetype was released for, eg. 2.1.8.1 .</p> - -<p>#####Staging repository#####</p> - -<p>If the above command will fail because of missing archetypes in central repository, you can try to use staging repository like below</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -mvn archetype:generate -B \ - -DgroupId=tutorial \ - -DartifactId=tutorial \ - -DarchetypeGroupId=org.apache.struts \ - -DarchetypeArtifactId=struts2-archetype-blank \ - -DarchetypeVersion=<version> - -DarchetypeCatalog=http://people.apache.org/builds/struts/<version>/m2-staging-repository/ - -</code></pre> -</div> - -<p>####Project Structure####</p> - -<p>The source code structure follows the normal <a href="http://maven\.apache\.org/guides/introduction/introduction\-to\-the\-standard\-directory\-layout\.html">Maven directory structure</a>^[http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html]. The blank-archetype does not include all of the directories listed in the Maven structure reference page.</p> - -<p>Our projectâs structure looks like this:</p> - -<table> - <thead> - <tr> - <th>Directory</th> - <th>Description</th> - </tr> - </thead> - <tbody> - <tr> - <td>src</td> - <td>All project source</td> - </tr> - <tr> - <td>¦- main</td> - <td>Primary source directory</td> - </tr> - <tr> - <td>¦  ¦- java</td> - <td>Java source code</td> - </tr> - <tr> - <td>¦  ¦  `- tutorial</td> - <td>Package defined by groupId parameter</td> - </tr> - <tr> - <td>¦  ¦     `- example</td> - <td>The example actions from the archetype</td> - </tr> - <tr> - <td>¦  ¦- resources</td> - <td>Resources (config, property, and validation files, and so on</td> - </tr> - <tr> - <td>¦  ¦  `-tutorial</td> - <td>Package defined by groupId parameter</td> - </tr> - <tr> - <td>¦  ¦     `- example</td> - <td>Example property and validation files from archetype</td> - </tr> - <tr> - <td>¦  `- webapp</td> - <td>Web application files (HTML, JSP, etc.)</td> - </tr> - <tr> - <td>¦      `- WEB-INF</td> - <td>Typical WEB-INF folder</td> - </tr> - <tr> - <td>¦         `- example</td> - <td>Files from archetype</td> - </tr> - <tr> - <td>`- test</td> - <td>Test code (unit tests etc.)</td> - </tr> - <tr> - <td>   `- java</td> - <td>Java-based test code</td> - </tr> - <tr> - <td>      `- tutorial</td> - <td>Package defined by groupId parameter</td> - </tr> - <tr> - <td>         `- example</td> - <td>Test code from archetype</td> - </tr> - </tbody> -</table> - -<p>#####Structure Difference From Non-Maven Projects#####</p> - -<p>One big change for folks not used to the Maven structure is the separation of Java source code and resource files. For example, in a non-Maven project our directory structure might look like this:</p> - -<table> - <thead> - <tr> - <th>src</th> - <th>All project source</th> - </tr> - </thead> - <tbody> - <tr> - <td>¦- tutorial</td> - <td>Tutorial package</td> - </tr> - <tr> - <td>¦  `- example</td> - <td>Example package</td> - </tr> - <tr> - <td>¦     ¦- Login.java</td> - <td>Login action source</td> - </tr> - <tr> - <td>¦     ¦- package.properties</td> - <td>Resource file</td> - </tr> - <tr> - <td>¦     `- Login-validation.xml</td> - <td>Validation file</td> - </tr> - <tr> - <td>`- struts.xml</td> - <td>Struts 2 config file</td> - </tr> - <tr> - <td>web</td> - <td>Web app files</td> - </tr> - <tr> - <td>¦- WEB-INF</td> - <td>Typical WEB-INF folder</td> - </tr> - <tr> - <td>`- index.html</td> - <td>An HTML file</td> - </tr> - </tbody> -</table> - -<p>It can take a little while to get used to, but ultimately it provides good separation of âtypesâ of things, and becomes second-nature pretty quickly. Note that itâs possible to use a non-Maven directory layout with Maven projects, but this can be challenging at some points.</p> - -<p>####Building The Project####</p> - -<p>There are several different ways we can go about building our project, from simple compilation up to actually running the web application--all from within Maven.</p> - -<p>#####Compilation#####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn compile -</code></pre> -</div> - -<p>will create a</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>target -</code></pre> -</div> -<p>directory containing the compiled classes. By itself this isnât terribly useful.</p> - -<p>#####Testing#####</p> - -<p>Running</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn test -</code></pre> -</div> - -<p>will compile the application and run the included unit tests. Blank-archetypeâs unit tests are <em>not</em> extensive, but provide a simple starting point for writing more complex, application-specific tests.</p> - -<p>One weâve run the Maven test command weâll notice thereâs a</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>target/surefire-reports -</code></pre> -</div> -<p>directory. The <a href="http://maven\.apache\.org/plugins/maven\-surefire\-plugin/">Maven Surefire Plugin</a>^[http://maven.apache.org/plugins/maven-surefire-plugin/] is how Maven runs our unit tests. By default it will create test results in XML and text formats in the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>target/surefire-reports -</code></pre> -</div> -<p>directory. These files can be examined to get further information regarding the failed tests.</p> - -<p>#####Assembling (Creating a WAR)#####</p> - -<p>#####Running#####</p> - -<p>We can run blank-archetype using the <a href="http://www\.mortbay\.org/jetty/">Jetty</a>^[http://www.mortbay.org/jetty/] server via the <a href="http://docs\.codehaus\.org/display/JETTY/Maven\+Jetty\+Plugin">Maven Jetty Plugin</a>^[http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin] by executing the Jetty pluginâs</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>run -</code></pre> -</div> -<p>command:</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn jetty:run -</code></pre> -</div> - -<p>Once weâve run the application we can see that it works by visiting</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>localhost:8080/tutorial/example/Welcome.action -</code></pre> -</div> -<p>as a sanity check.</p> - -<p>####Application Documentation####</p> - -<p>The application consists of a few test actions demonstrating simple validation and package-level property (resource) files. The most interesting URLs are as follows (assuming we used</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>groupId=tutorial -</code></pre> -</div> -<p>):</p> - -<table> - <thead> - <tr> - <th>URL</th> - <th>Description</th> - </tr> - </thead> - <tbody> - <tr> - <td>/tutorial/example/Welcome.action</td> - <td>Handled by wildcard mapping</td> - </tr> - <tr> - <td>/tutorial/example/HelloWorld.action</td> - <td>Handled by explicit mapping, demonstrates package-level properties</td> - </tr> - <tr> - <td>/tutorial/example/Login.action</td> - <td>Handled by explicit mapping with method wilcard (see the Login.action documentation for information regarding how to access this URL)</td> - </tr> - </tbody> -</table> - -<p>#####Application Configuration#####</p> - -<p>The default Struts 2 configuration file is contained in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>src/main/resources/struts.xml -</code></pre> -</div> -<p>. It includes an additional configuration file,</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>src/main/resources/example.xml -</code></pre> -</div> -<p>. The applicationâs mappings are contained in the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>example.xml -</code></pre> -</div> -<p>file. The</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml -</code></pre> -</div> -<p>file sets some constants.</p> - -<p>See the <em>struts.xml</em> page for more information about the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml -</code></pre> -</div> -<p>file. For more information regarding whatâs contained in typical</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml -</code></pre> -</div> -<p>files start at the <em>Configuration Elements</em> page, which contains links to a bunch of information. See the <em>Configuration Files</em> page for more information regarding additional Struts 2 configuration files, including links to the files that set all the Struts 2 default configurations.</p> - -<p>#####Welcome.action#####</p> - -<p>The mapping for this action is handled by a âcatch-allâ mapping in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>example.xml -</code></pre> -</div> -<p>:</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -<action name="*" class="tutorial2.example.ExampleSupport"> - <result>/example/{1}.jsp</result> -</action> - -</code></pre> -</div> - -<p>This mapping is the last mapping contained in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>example.xml -</code></pre> -</div> -<p>--anything not handled by mappings appearing before it in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>example.xml -</code></pre> -</div> -<p>will be caught by this mapping. This mapping will look for JSP files in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>src/main/webapp/example/*.jsp -</code></pre> -</div> -<p>. Since thereâs a</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>Welcome.jsp -</code></pre> -</div> -<p>in that directory, weâre all set. See the <em>Wildcard Mappings</em> page for more information on how Struts 2 can use wildcard mappings.</p> - -<p>#####HelloWorld.action#####</p> - -<p>The mapping executes the HelloWorld action, contained in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>src/main/java/tutorial/example/HelloWorld.action -</code></pre> -</div> -<p>. This action retrieves a message from a package-level properties file, contained in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>src/main/resources/tutorial/package.properties -</code></pre> -</div> -<p>. See the <em>Localization</em> page for more information about how Struts 2 handles message resources (itâs pretty cool).</p> - -<p>#####Login.action#####</p> - -<p>This is another wildcard mapping:</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -<action name="Login_*" method="{1}" class="tutorial2.example.Login"> - <result name="input">/example/Login.jsp</result> - <result type="redirectAction">Menu</result> -</action> - -</code></pre> -</div> - -<p>In the application the Login action is reached via a link, but not directly to</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>/tutorial/example/Login.action -</code></pre> -</div> -<p>. The link is actually</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>/tutorial/example/Login_input.action -</code></pre> -</div> -<p>. Reaching the Login action this way bypasses validation: if we hit the Login action directly weâll get a validation error.</p> - -<p>The validation configuration is contained in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>/src/main/resources/tutorial/example/Login-validation.xml -</code></pre> -</div> -<p>. It checks for the presence of the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>username -</code></pre> -</div> -<p>and</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>password -</code></pre> -</div> -<p>properties (form values). It uses messages stored in the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>package.properties +<div class="highlighter-rouge"><pre class="highlight"><code> mvn jetty:run </code></pre> </div> -<p>file (in the same directory). See the <em>Validation</em> page for more information regarding Struts 2 validation.</p> </section> </article> http://git-wip-us.apache.org/repos/asf/struts-site/blob/a52b99d1/content/maven-archetypes/struts2-archetype-blank.html ---------------------------------------------------------------------- diff --git a/content/maven-archetypes/struts2-archetype-blank.html b/content/maven-archetypes/struts2-archetype-blank.html new file mode 100644 index 0000000..f5b87b8 --- /dev/null +++ b/content/maven-archetypes/struts2-archetype-blank.html @@ -0,0 +1,507 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="Date-Revision-yyyymmdd" content="20140918"/> + <meta http-equiv="Content-Language" content="en"/> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + + <title>Struts 2 Blank Archetype</title> + + <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css"> + <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> + <link href="/css/main.css" rel="stylesheet"> + <link href="/css/custom.css" rel="stylesheet"> + <link href="/highlighter/github-theme.css" rel="stylesheet"> + + <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> + <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script> + <script type="text/javascript" src="/js/community.js"></script> +</head> +<body> + +<a href="http://github.com/apache/struts" class="github-ribbon"> + <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"> +</a> + +<header> + <nav> + <div role="navigation" class="navbar navbar-default navbar-fixed-top"> + <div class="container"> + <div class="navbar-header"> + <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle"> + Menu + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a> + </div> + <div id="struts-menu" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li class="dropdown"> + <a data-toggle="dropdown" href="#" class="dropdown-toggle"> + Home<b class="caret"></b> + </a> + <ul class="dropdown-menu"> + <li><a href="/index.html">Welcome</a></li> + <li><a href="/downloads.html">Downloads</a></li> + <li><a href="/announce.html">Announcements</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li> + </ul> + </li> + <li class="dropdown"> + <a data-toggle="dropdown" href="#" class="dropdown-toggle"> + Support<b class="caret"></b> + </a> + <ul class="dropdown-menu"> + <li><a href="/mail.html">User Mailing List</a></li> + <li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li> + <li><a href="/security.html">Reporting Security Issues</a></li> + <li class="divider"></li> + <li><a href="/maven/project-info.html">Project info</a></li> + <li><a href="/maven/struts2-core/dependencies.html">Struts Core dependencies</a></li> + <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li> + </ul> + </li> + <li class="dropdown"> + <a data-toggle="dropdown" href="#" class="dropdown-toggle"> + Documentation<b class="caret"></b> + </a> + <ul class="dropdown-menu"> + <li><a href="/birdseye.html">Birds Eye</a></li> + <li><a href="/primer.html">Key Technologies</a></li> + <li><a href="/kickstart.html">Kickstart FAQ</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li> + <li class="divider"></li> + <li><a href="/getting-started/">Getting Started</a></li> + <li><a href="/security/">Security Guide</a></li> + <li><a href="/core-developers/">Core Developers Guide</a></li> + <li><a href="/tag-developers/">Tag Developers Guide</a></li> + <li><a href="/maven-archetypes/">Maven Archetypes</a></li> + <li><a href="/plugins/">Plugins</a></li> + <li class="divider"></li> + <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li> + <li><a href="/docs/plugins.html">Plugin APIs</a></li> + <li><a href="/docs/tag-reference.html">Tag reference</a></li> + <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li> + <li class="divider"></li> + <li><a href="/docs/tutorials.html">Tutorials - DEPRECATED</a></li> + <li><a href="/docs/faqs.html">FAQs - DEPRECATED</a></li> + <li><a href="/docs/guides.html">Guides - DEPRECATED</a></li> + </ul> + </li> + <li class="dropdown"> + <a data-toggle="dropdown" href="#" class="dropdown-toggle"> + Contributing<b class="caret"></b> + </a> + <ul class="dropdown-menu"> + <li><a href="/youatstruts.html">You at Struts</a></li> + <li><a href="/helping.html">How to Help FAQ</a></li> + <li><a href="/dev-mail.html">Development Lists</a></li> + <li class="divider"></li> + <li><a href="/submitting-patches.html">Submitting patches</a></li> + <li><a href="/builds.html">Source Code</a></li> + <li><a href="/coding-standards.html">Coding standards</a></li> + <li class="divider"></li> + <li><a href="/releases.html">Release Guidelines</a></li> + <li><a href="/bylaws.html">PMC Charter</a></li> + <li><a href="/volunteers.html">Volunteers</a></li> + <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source Repository</a></li> + </ul> + </li> + <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li> + </ul> + </div> + </div> + </div> + </nav> +</header> + + +<article class="container"> + <section class="col-md-12"> + <a href="index.html" title="back to Maven Archetypes"><< back to Maven Archetypes</a> + <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/maven-archetypes/struts2-archetype-blank.md" title="Edit this page on GitHub">Edit on GitHub</a> + <h1 id="struts-2-blank-archetype">Struts 2 Blank Archetype</h1> + +<p>The Struts 2 Blank Archetype (âblank-archetypeâ) provides a minimal, but complete, Struts 2 application. It demonstrates some of the most basic Struts 2 concepts.</p> + +<p><strong>Features</strong></p> + +<ul> + <li> + <p>XML-based configuration, demonstrates including additional config file</p> + </li> + <li> + <p>Example actions</p> + </li> + <li> + <p>Package-level resource bundle</p> + </li> + <li> + <p>XML-based validation</p> + </li> + <li> + <p>Unit-testing</p> + </li> +</ul> + +<p class="no_toc"><strong>Contents</strong></p> + +<ul id="markdown-toc"> + <li><a href="#struts-2-blank-archetype" id="markdown-toc-struts-2-blank-archetype">Struts 2 Blank Archetype</a> <ul> + <li><a href="#creating-our-blank-archetype-project" id="markdown-toc-creating-our-blank-archetype-project">Creating Our blank-archetype Project</a> <ul> + <li><a href="#staging-repository" id="markdown-toc-staging-repository">Staging repository</a></li> + </ul> + </li> + <li><a href="#project-structure" id="markdown-toc-project-structure">Project Structure</a> <ul> + <li><a href="#structure-difference-from-non-maven-projects" id="markdown-toc-structure-difference-from-non-maven-projects">Structure Difference From Non-Maven Projects</a></li> + </ul> + </li> + <li><a href="#building-the-project" id="markdown-toc-building-the-project">Building The Project</a> <ul> + <li><a href="#compilation" id="markdown-toc-compilation">Compilation</a></li> + <li><a href="#testing" id="markdown-toc-testing">Testing</a></li> + <li><a href="#assembling-creating-a-war" id="markdown-toc-assembling-creating-a-war">Assembling (Creating a WAR)</a></li> + <li><a href="#running" id="markdown-toc-running">Running</a></li> + </ul> + </li> + <li><a href="#application-documentation" id="markdown-toc-application-documentation">Application Documentation</a> <ul> + <li><a href="#application-configuration" id="markdown-toc-application-configuration">Application Configuration</a></li> + <li><a href="#welcomeaction" id="markdown-toc-welcomeaction">Welcome.action</a></li> + <li><a href="#helloworldaction" id="markdown-toc-helloworldaction">HelloWorld.action</a></li> + <li><a href="#loginaction" id="markdown-toc-loginaction">Login.action</a></li> + </ul> + </li> + </ul> + </li> +</ul> + +<h2 id="creating-our-blank-archetype-project">Creating Our blank-archetype Project</h2> + +<p>Weâll run the following command from our projectâs parent directory (this is shown using Unix-style commands).</p> + +<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn archetype:generate -B \ + -DgroupId=tutorial \ + -DartifactId=tutorial \ + -DarchetypeGroupId=org.apache.struts \ + -DarchetypeArtifactId=struts2-archetype-blank \ + -DarchetypeVersion=<version> +$ ls +tutorial/ +$ cd tutorial +$ ls +pom.xml src/ +</code></pre> +</div> + +<p>Depending on the state of your local system you may see Maven downloading various libraries (known as âdownloading the internetâ, which is what it seems Maven does sometimes). Be patient â Maven is basically setting up your required libraries automatically. +<strong><version></strong> - is the version of Struts 2 you want to use and archetype was released for, e.g. 2.1.8.1 .</p> + +<h3 id="staging-repository">Staging repository</h3> + +<p>If the above command will fail because of missing archetypes in central repository, you can try to use staging repository like below</p> + +<div class="highlighter-rouge"><pre class="highlight"><code>mvn archetype:generate -B \ + -DgroupId=tutorial \ + -DartifactId=tutorial \ + -DarchetypeGroupId=org.apache.struts \ + -DarchetypeArtifactId=struts2-archetype-blank \ + -DarchetypeVersion=<version> + -DarchetypeCatalog=http://people.apache.org/builds/struts/<version>/m2-staging-repository/ +</code></pre> +</div> + +<h2 id="project-structure">Project Structure</h2> + +<p>The source code structure follows the normal <a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Maven directory structure</a>. The blank-archetype does not include all of the directories listed in the Maven structure reference page.</p> + +<p>Our projectâs structure looks like this:</p> + +<table> + <thead> + <tr> + <th>Directory</th> + <th>Description</th> + </tr> + </thead> + <tbody> + <tr> + <td>src</td> + <td>All project source</td> + </tr> + <tr> + <td>src/main</td> + <td>Primary source directory</td> + </tr> + <tr> + <td>src/main/java</td> + <td>Java source code</td> + </tr> + <tr> + <td>src/main/java/tutorial</td> + <td>Package defined by groupId parameter</td> + </tr> + <tr> + <td>src/main/java/tutorial/example</td> + <td>The example actions from the archetype</td> + </tr> + <tr> + <td>src/main/resources</td> + <td>Resources (config, property, and validation files, and so on</td> + </tr> + <tr> + <td>src/main/resources/tutorial</td> + <td>Package defined by groupId parameter</td> + </tr> + <tr> + <td>src/main/resources/tutorial/example</td> + <td>Example property and validation files from archetype</td> + </tr> + <tr> + <td>src/main/webapp</td> + <td>Web application files (HTML, JSP, etc.)</td> + </tr> + <tr> + <td>src/main/webapp/WEB-INF</td> + <td>Typical WEB-INF folder</td> + </tr> + <tr> + <td>src/main/webapp/WEB-INF/example</td> + <td>Files from archetype</td> + </tr> + <tr> + <td>src/test</td> + <td>Test code (unit tests etc.)</td> + </tr> + <tr> + <td>src/test/java</td> + <td>Java-based test code</td> + </tr> + <tr> + <td>src/test/java/tutorial</td> + <td>Package defined by groupId parameter</td> + </tr> + <tr> + <td>src/test/java/tutorial/example</td> + <td>Test code from archetype</td> + </tr> + </tbody> +</table> + +<h3 id="structure-difference-from-non-maven-projects">Structure Difference From Non-Maven Projects</h3> + +<p>One big change for folks not used to the Maven structure is the separation of Java source code and resource files. For example, in a non-Maven project our directory structure might look like this:</p> + +<table> + <thead> + <tr> + <th>Directory</th> + <th>Description</th> + </tr> + </thead> + <tbody> + <tr> + <td>src</td> + <td>All project source</td> + </tr> + <tr> + <td>src/tutorial</td> + <td>Tutorial package</td> + </tr> + <tr> + <td>src/tutorial/example</td> + <td>Example package</td> + </tr> + <tr> + <td>src/tutorial/example/Login.java</td> + <td>Login action source</td> + </tr> + <tr> + <td>src/tutorial/example/package.properties</td> + <td>Resource file</td> + </tr> + <tr> + <td>src/tutorial/example/Login-validation.xml</td> + <td>Validation file</td> + </tr> + <tr> + <td>src/struts.xml</td> + <td>Struts 2 config file</td> + </tr> + <tr> + <td>web</td> + <td>Web app files</td> + </tr> + <tr> + <td>web/WEB-INF</td> + <td>Typical WEB-INF folder</td> + </tr> + <tr> + <td>web/index.html</td> + <td>An HTML file</td> + </tr> + </tbody> +</table> + +<p>It can take a little while to get used to, but ultimately it provides good separation of âtypesâ of things, and becomes second-nature pretty quickly. Note that itâs possible to use a non-Maven directory layout with Maven projects, but this can be challenging at some points.</p> + +<h2 id="building-the-project">Building The Project</h2> + +<p>There are several different ways we can go about building our project, from simple compilation up to actually running the web application â all from within Maven.</p> + +<h3 id="compilation">Compilation</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn compile +</code></pre> +</div> + +<p>will create a <code class="highlighter-rouge">target</code> directory containing the compiled classes. By itself this isnât terribly useful.</p> + +<h3 id="testing">Testing</h3> + +<p>Running</p> + +<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn test +</code></pre> +</div> + +<p>will compile the application and run the included unit tests. Blank-archetypeâs unit tests are <em>not</em> extensive, but provide a simple starting point for writing more complex, application-specific tests.</p> + +<p>Once weâve run the Maven test command weâll notice thereâs a <code class="highlighter-rouge">target/surefire-reports</code> directory. The <a href="http://maven.apache.org/plugins/maven-surefire-plugin/">Maven Surefire Plugin</a> is how Maven runs our unit tests. By default it will create test results in XML and text formats in the <code class="highlighter-rouge">target/surefire-reports</code> directory. These files can be examined to get further information regarding the failed tests.</p> + +<h3 id="assembling-creating-a-war">Assembling (Creating a WAR)</h3> + +<h3 id="running">Running</h3> + +<p>We can run blank-archetype using the <a href="http://www.mortbay.org/jetty/">Jetty</a> server via the <a href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin">Maven Jetty Plugin</a> by executing the Jetty pluginâs <code class="highlighter-rouge">run</code> command:</p> + +<div class="highlighter-rouge"><pre class="highlight"><code>$ mvn jetty:run +</code></pre> +</div> + +<p>Once weâve run the application we can see that it works by visiting <code class="highlighter-rouge">localhost:8080/tutorial/example/Welcome.action</code> as a sanity check.</p> + +<h2 id="application-documentation">Application Documentation</h2> + +<p>The application consists of a few test actions demonstrating simple validation and package-level property (resource) files. The most interesting URLs are as follows (assuming we used <code class="highlighter-rouge">groupId=tutorial</code>):</p> + +<table> + <thead> + <tr> + <th>URL</th> + <th>Description</th> + </tr> + </thead> + <tbody> + <tr> + <td>/tutorial/example/Welcome.action</td> + <td>Handled by wildcard mapping</td> + </tr> + <tr> + <td>/tutorial/example/HelloWorld.action</td> + <td>Handled by explicit mapping, demonstrates package-level properties</td> + </tr> + <tr> + <td>/tutorial/example/Login.action</td> + <td>Handled by explicit mapping with method wilcard (see the Login.action documentation for information regarding how to access this URL)</td> + </tr> + </tbody> +</table> + +<h3 id="application-configuration">Application Configuration</h3> + +<p>The default Struts 2 configuration file is contained in <code class="highlighter-rouge">src/main/resources/struts.xml</code>. It includes an additional configuration file, <code class="highlighter-rouge">src/main/resources/example.xml</code>. The applicationâs mappings are contained in the <code class="highlighter-rouge">example.xml</code> file. The <code class="highlighter-rouge">struts.xml</code> file sets some constants.</p> + +<p>See the <a href="/core-developers/struts-xml.html">struts.xml page</a> for more information about the <code class="highlighter-rouge">struts.xml</code> file. For more information regarding whatâs contained in typical <code class="highlighter-rouge">struts.xml</code> files start at the <a href="/core-developers/configuration-elements.html">Configuration Elements page</a>, which contains links to a bunch of information. See the <a href="/core-developers/configuration-files.html">Configuration Files</a> page for more information regarding additional Struts 2 configuration files, including links to the files that set all the Struts 2 default configurations.</p> + +<h3 id="welcomeaction">Welcome.action</h3> + +<p>The mapping for this action is handled by a âcatch-allâ mapping in <code class="highlighter-rouge">example.xml</code>:</p> + +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><action</span> <span class="na">name=</span><span class="s">"*"</span> <span class="na">class=</span><span class="s">"tutorial2.example.ExampleSupport"</span><span class="nt">></span> + <span class="nt"><result></span>/example/{1}.jsp<span class="nt"></result></span> +<span class="nt"></action></span> +</code></pre> +</div> + +<p>This mapping is the last mapping contained in <code class="highlighter-rouge">example.xml</code> â anything not handled by mappings appearing before it in <code class="highlighter-rouge">example.xml</code> will be caught by this mapping. This mapping will look for JSP files in <code class="highlighter-rouge">src/main/webapp/example/*.jsp</code>. Since thereâs a <code class="highlighter-rouge">Welcome.jsp</code> in that directory, weâre all set. See the <a href="/core-developers/wildcard-mappings.html">Wildcard Mappings page</a> for more information on how Struts 2 can use wildcard mappings.</p> + +<h3 id="helloworldaction">HelloWorld.action</h3> + +<p>The mapping executes the HelloWorld action, contained in <code class="highlighter-rouge">src/main/java/tutorial/example/HelloWorld.action</code>. This action retrieves a message from a package-level properties file, contained in <code class="highlighter-rouge">src/main/resources/tutorial/package.properties</code>. See the <a href="/core-developers/localization.html">Localization page</a> for more information about how Struts 2 handles message resources (itâs pretty cool).</p> + +<h3 id="loginaction">Login.action</h3> + +<p>This is another wildcard mapping:</p> + +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><action</span> <span class="na">name=</span><span class="s">"Login_*"</span> <span class="na">method=</span><span class="s">"{1}"</span> <span class="na">class=</span><span class="s">"tutorial2.example.Login"</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"input"</span><span class="nt">></span>/example/Login.jsp<span class="nt"></result></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"redirectAction"</span><span class="nt">></span>Menu<span class="nt"></result></span> +<span class="nt"></action></span> +</code></pre> +</div> + +<p>In the application the Login action is reached via a link, but not directly to <code class="highlighter-rouge">/tutorial/example/Login.action</code>. The link is actually <code class="highlighter-rouge">/tutorial/example/Login_input.action</code>. Reaching the Login action this way bypasses validation: if we hit the Login action directly weâll get a validation error.</p> + +<p>The validation configuration is contained in <code class="highlighter-rouge">/src/main/resources/tutorial/example/Login-validation.xml</code>. It checks for the presence of the <code class="highlighter-rouge">username</code> and <code class="highlighter-rouge">password</code> properties (form values). It uses messages stored in the <code class="highlighter-rouge">package.properties</code> file (in the same directory). See the <a href="/core-developers/validation.html">Validation page</a> for more information regarding Struts 2 validation.</p> + + </section> +</article> + + +<footer class="container"> + <div class="col-md-12"> + Copyright © 2000-2016 <a href="http://www.apache.org/">The Apache Software Foundation </a>. + All Rights Reserved. + </div> + <div class="col-md-12"> + Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are + trademarks of The Apache Software Foundation. + </div> + <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div> +</footer> + +<script>!function (d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0]; + if (!d.getElementById(id)) { + js = d.createElement(s); + js.id = id; + js.src = "//platform.twitter.com/widgets.js"; + fjs.parentNode.insertBefore(js, fjs); + } +}(document, "script", "twitter-wjs");</script> +<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script> + +<div id="fb-root"></div> + +<script>(function (d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) return; + js = d.createElement(s); + js.id = id; + js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; + fjs.parentNode.insertBefore(js, fjs); +}(document, 'script', 'facebook-jssdk'));</script> + + +<script> +$(function() { + return $("h2, h3, h4, h5, h6").each(function(i, el) { + var $el, id; + $el = $(el); + id = $el.attr('id'); + if (id) { + $el.removeAttr('id'); + return $el.before($("<a />").addClass('anchor').attr('name', id)); + } + }); +}); +</script> + +</body> +</html>