Creating a web application

Now that we have a simple Maven project let's expand this to create an actual web application. The first thing we are going to do is create a WEB-INF folder and a web.xml file, because these are what define a Java web application.

Follow these steps to turn the structure you have now into a Maven web application structure. 

  1. Create a folder called webapp directly under the main folder. This is where web application sources go according to Maven's Standard Directory Layout. 
  2. In webapp create a folder called WEB-INF
  3. In WEB-INF create a file called web.xml

    Maven webapp structure 

 Web.xml is now still empty, so let's put some basic stuff in there.

(By the way: With the small red cross icon, Eclipse is indicating that something is wrong with the project. Eclipse is wrong. We are right. Don't pay attention to it. And get a professional IDE like Intellij if you are serious about development.)

  • Copy the following XML into your web.xml.
<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns=""

    <display-name>My Spring MVC web application</display-name>


This is just a very basic web.xml file as you can see. We will add configurations to it later when we configure Spring.

On the next page we are going to provide some dependencies and other settings in pom.xml. In other words, we are going to tell Maven what to do.