Spring MVC Basic Setup and Hello World

Spring mVC basic Setup
Spring MVC Setup

In this tutorial, we will show you a  Spring  MVC, Hello World Example and do a basic Setup Using Eclipse .

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.

Please Comment Like Share and Subscribe !

 



1 Trackback / Pingback

  1. Spring Boot Profiling - Configure for Different Environments - FrugalisMinds

Leave a Reply

Your email address will not be published.


*