Spring MVC Basic Setup and Hello World

Spring mVC basic Setup
Spring MVC Setup

Spring MVC Setup and Hello World:-

In this tutorial, we will show you a  Spring  MVC, Hello World Example and do a basic Setup Using Eclipse . Spring MVC Container is an  extended version of  IOC container. We are going to setup a simple Spring MVC example using maven.

There are number of ways with which we can setup , but i am showing most basic one .

Technologies used :-

  1. Spring
  2. Eclipse 4.4
  3. JDK 1.7

1. Project Structure

2. Spring MVC

2.1 Download Spring Related Jars From here

2.2  Create Your web.xml accordingly .

2.3 Create Dispatcher Configurations:-

We need to create a file named dispatcher-servlet.xml in web-inf Folder and create a Folder named as views, where all your JSP files will reside.

For Views or JSP we need to configure ViewResolver as well.

In the above configurationdispatcher-servlet.xml file, we have defined a tag.<context:component-scan> This will allow Spring to load all the components from the package org.codestrs.controller  and all its child packages.

This loads.BaseAnnotated.class Also, we have defined a bean viewResolver. This bean will resolve the view and add prefix string,/WEB-INF/views/ and suffix .jsp to the view in ModelAndView. Note that in our BaseAnnotatedclass, we have return a ModelAndView object with view name welcome. This will be resolved to path /WEB-INF/jsp/index.jsp .

2.4 Create Controller

That’s All , You have Configured your basic Spring Boot Application . Watch Video for more eclipse settings if you have any queries.Spring mvc setup will clear your basic knowledge. If you want to make your concepts regarding spring mvc setup  there is a very good book on Spring MVC 4 , You can learn basics of MVC , though we do using java Config but it has very much explanation using xml approach .XM approach will make your concepts clear .

Please Comment Like Share and Subscribe !




Please enter your comment!
Please enter your name here