This post is a step by step guide for a Hello world using Spring-MVC. I am using Eclipse (Mars Edition) and Apache Tomcat for this tutorial. Also I am using Maven for build automation. If you are beginner or  if you have not yet configured your workspace then I recommend these links before reading any further.

Step 1: Create a new Dynamic Web Application

Create a new dynamic web application (named SpringHelloWorld for this tutorial). Also convert the project into ‘Maven Project’ (This is an optional step if you are planning to use Maven).

Step 2: Update dependencies for Spring MVC

Add these dependencies to pom.xml

If you are not using Maven then download the following jar versions into WEB-INF/lib folder.

spring-webmvc.jar -> 4.2.4 Version
spring-beans.jar -> 4.2.4 Version
spring-context.jar -> 4.2.4 Version
spring-aop.jar -> 4.2.4 Version
aopalliance.jar -> 1.0 Version
spring-core.jar -> 4.2.4 Version
commons-logging.jar -> 1.2 Version
spring-expression.jar -> 4.2.4 Version
spring-web.jar -> 4.2.4 Version

Step 3: Add code for REST Service

Spring MVC Hello World

WebConfig

Jsp

Create this jsp SpringHelloWorld/WebContent/WEB-INF/views/ folder.

Controller

Deployment Descriptor

Copy paste this code into web.xml

Output

Open a browser and enter address http://localhost:/SpringHelloWorld/helloworld/test.

Hello World Sring MVC Output

Hope this helps!!
Learn and Share