While the framework is simple to use, creating non-trivial applications assumes a working knowledge of many JEE technologies, including:
A distribution can be downloaded from the Apache Struts website. The full distribution contains:
struts2-core.jar
fileBlank Application
The blank web application in the distribution's apps directory is meant as a template.
There is even a simple batch file in the source code directory that we can use to recompile the application in place.
We can make a copy of the blank.war
, deploy it to our container, and use the exploded copy as the basis for our application.
For those of us using Maven as a build system, we can use the Maven Archetype to create a new application.
First consult the maven archetype catalog
mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/
you can use one of the following achetypes:
The Blank Convention Archetype (struts2-archetype-convention)
It has the following features:
to download it trough maven run the command
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
The Blank Archetype (struts2-archetype-blank)
It has the following features:
to download it trough maven run the command
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
The Starter Archetype (struts2-archetype-starter)
It has the following features:
to download it trough maven run the command
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
The AngularJS Archetype (struts2-archetype-angularjs)
It has the following features:
to download it trough maven run the command
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
The Portlet Blank Archetype (struts2-archetype-portlet)
It has the following features:
View, Edit, and Help mode examples
to download it trough maven run the command
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
The Portlet Database Archetype (struts2-archetype-dbportlet)
It has the following features:
Uses Spring and Hsql to show a real database query
to download it trough maven run the command
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
The Plugin Archetype (struts2-archetype-plugin)
It has the following features:
to download it trough maven run the command
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