View the console where you should see numerous debug messages that tell you the Struts 2 framework is being included in the basic-struts2 web application. Run mvn jetty:run to run the web-application using the jetty maven-plugin. This minimal Struts 2 configuration file tells the framework that if the URL ends in index.action to redirectįor more information about the struts.xml configuration file see struts.xml. Must be on the web application’s root class path). Note the file name is struts.xml and it should be in the src/main/resources folder ( struts.xml For our basic Struts 2 application, we’ll use a minimal xmlĬonfiguration. Struts 2 can use either an XML configuration file or annotations (or both) to specify the relationship between a URL,Ī Java class, and a view page (such as index.jsp). Value is /* meaning the Struts 2 filter will be applied to all URLs for this web application. Basic Struts2 index struts2 .filter.StrutsPrepareAndExecuteFilter struts2 /* įor more information about configuring the deployment descriptor for Struts 2 see Core Developers Guide / web.xml page. web.xml is to be under src/main/webapp/WEB-INF folder. Below is how the web.xml may look after adding the filter and filter-mapping nodes. To enable the Struts 2 framework to work with your web application you need to add a Servlet filter class and filter
jetty-maven-plugin 9.4.7.v20170914 /$ import pom struts2-core 4j log4j-core Step 5 - Add Struts 2 Servlet Filter In your Java IDE create a Java web application with a project name of basic_struts that follows the standard Maven
#How to run jar of beans without vtx how to
This tutorial assumes you know how to create a Java web application that uses Maven to manage artifacts and build Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application You can checkout all the example applications from the Struts 2 GitHub repositoryĪt struts-examples. To get started using Struts 2 we will create a web application using Maven to manage the artifact dependencies.
Struts 2 requires Servlet API 2.4 or higher, JSP 2.0 or higher, and Java 7 or higher. While the Struts 2 framework is simple to use, creating non-trivial applications assumes a working knowledgeįor more about supporting technologies, see the Key Technologies Primer. This tutorial walks through installing the framework and creating a simple application.
Edit on GitHub << back to Getting started How To Create A Struts 2 Web Application