You can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Spring MVC Hello World, Spring MVC 3.2 Hello World Example In Eclipse

Spring-MVC » On Jul 14, 2013 By Sivateja

Let us execute spring MVC hello world application with complete explanation, will see it in an eclipse :-)

Open eclipse > File  > Dynamic Web Project

Give Project Name > Finish

Directory Structure

Required Files

  • welcomePage.jsp
  • web.xml
  • welcome-servlet.xml
  • index.jsp





Execution Flow

  • Run the application, then index.jsp file will be executed > click on the link given (I have given <a href=”java4s.html”>Click here to check the output :-)</a>)
  • Once you click on that link, container will check the URL pattern at web.xml and passes the request to the DispatcherServlet
  • DispatcherServlet then passes that request to our controller class
  • Actually we are passing java4s.html from index.jsp right ? so DispatcherServlet verifies this ‘java4s’ name with the string in @RequestMapping(“-”) in our controller class if same it will executes the following method, which gives ModelAndView object as return type

In our controller class we are returning…

Means first argument is ‘View’ page name [ Where we are sending our result ], second, third arguments are key,values

  • So DispatcherServlet search for the name welcomePage in /jsp folder with extension .jsp [ you can change the ‘view page’ folder name/location and its extension in welcome-servlet.xml at line numbers 14,15],  once the file was opened you can access the data by using the key welcomeMessage [2nd parameter in ModelAndView object]
  • Check welcomePage.jsp > i am printing the result by calling the key ${welcomeMessage}


  • In web.xml we have given servlet name as welcome, so spring configuration file name must be welcome-servlet.xml [ {servletName-in-web.xml}-servlet.xml ]


By ( Java/J2EE Developer & Web Designer )
Founder of You can contact me at sivateja [at]


17 Responses to “Spring MVC Hello World, Spring MVC 3.2 Hello World Example In Eclipse”
  1. ramana says:

    i am trying to execute Spring MVC Hello World program in Dynamic web project using eclipise it is rising java.lang.NoSuchMethodError:;Lorg/springframework/core/env/PropertyResolver;)

  2. GSolanki says:

    you should first explain the annotations such as @controller….,@requestmapping….
    you got it right

  3. B.Prasad says:

    what is the difference between comparable and comparator interfaces and give me one real time example please

  4. utkal samal says:

    HI ,
    I am sending the request from index.jsp as only java4s, but request is not happening,Could You please suggest me, why it is not happening ?????

  5. Prasanth says:

    Thank you , it is really helpful.

  6. Saroj Kumar says:

    In index.html, you have given “java4s.html” as href, but in controller class, you have given “/java4s” as parameter in @RequestMapping.
    You haven’t explain about how this is working.
    Please explain the same.


  7. Deepak Kumar says:


    Please add missing spring-aop-x.x.x.RELEASE.jar into WEB-INF\web folder. This will help you to run the above program without errors.

    Deepak Kumar

  8. prashant says:

    how to upload any pdf,image and store in MySql

  9. Loganathan says:

    Thank you so much. Really its makes me to understand the springflow very clearly. Once again thanks.

  10. Hi, Earlier I ran this example successfully. But now I am getting 404 error after clicking on a href link. Can u plz suggest.

    please note- I am just trying the example given above. I didn’t do any changes.

  11. Sachin says:

    Nice Explanation yar….

  12. hari krishna says:

    When i ran this example i am getting the below exception . Please assist.

    No mapping found for HTTP request with URI [/Spring_MVC/java4s.html] in DispatcherServlet with name ‘welcome’

  13. Dushyanth says:


    I see the warning : No mapping found for HTTP request with URI [/Mvc/] in DispatcherServlet with name ‘welcome’. How to overcome this ??

  14. Sebin+Joseph says:

    How DispatcherServlet knows Java4sController is the controller here in this program?

  15. Rishabh Chaturvedi says:

    Dear Sebin+Joseph,

    The same doubt I was having but according to me the ans is below->

    In line no -7(@Controller annotation used).
    This @Controller annotation indicates that a particular class serves the role of a controller and this is How DispatcherServlet knows about the controller class.
    All,Please correct me if I am wrong


  16. Rishabh+Chaturvedi says:

    Hey Sebin+joseph..

    According to me DispatcherServlet knows about the controller by @Controller Annotation which is used in line no 7 in
    This Annotation tells the DispatcherServlet about the particular class that will work as a Controller.

  17. Venkata Ramireddy CH says:

    I followed as it is given in your example. But after running my application, it is not reaching controller class. I am not seeing any error message in console. Infact it is showing 404 error message on click on the link.


By posting your answer, you agree to our comments policy.
So, What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs

Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links
Current & UpComing Tutorials
Sitemap :
spring Hibernate struts Json Ajax Log4j Log4j coreJava Servlets Web Services

  Web Services [ SOAP ], JSP
Facebook_Java4s  Twitter_Java4s  GooglePlus_Java4s  Youtube_Java4s 
© 2010 - 2015 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.