Spring Boot + Spring MVC + JSP Hello World Example

Spring-Boot-Tutorials » on May 17, 2018 { 5 Comments } By Sivateja

This article describes how to create a Spring MVC application using Spring Boot. As this is an MVC application unlike previous examples, we have to create a webapp folder under /src/main (src > main > webapp) where we will place all our .jsp files.



Final pom.xml

    xmlns:xsi="" xsi:schemaLocation="">

# Applicationn context name

# Spring MVC related

In the current example, I am going to put all my .jsp file(s) under /WEB-INF/jsp/ folder, no need to mention ‘webapp’ in the properties file as spring boot by default consider that folder and search under webapp.


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringBootApp {
    public static void main(String[] args) {, args);


import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

public class SpringJava4sController {

    public ModelAndView showLoginPage(Model model) {
        model.addAttribute("message", "Welcome to Java4s Spring Boot Tutorials");

        return new ModelAndView("welcomePage");




Run the application and hit http://localhost:8080/springbootmvc/


You Might Also Like

  ::. About the Author .::

Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


5 Responses to “Spring Boot + Spring MVC + JSP Hello World Example”
  1. Arun says:

    I think we should use @Controller in place of @RestController in

    • Nagarjun says:

      yeah correct. but if you want to return JSON data not possible with @controller, need to use @Restontroller

  2. Anonymous says:

    Really appriciate on your effort on SpringBoot and really you made it so easy and handy. It will be helpfull if you will add some medium scale project related to SpringBoot.


  3. Nagarjun says:

    which dependency we have to add for springMVC in POM.xml file
    in above program you added dependencies for spring boot, those dependencies work for spring also ?

  4. pam says:

    Can you please give an example to connect Spring with Angular JS?


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2023 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.