Easy learning with example program codes

spring boot + Spring MVC + Maven + JSP example

Spring boot is a module of spring framework which is used to create stand-alone, production-grade Spring based Applications with minimum programmer’s efforts. It is developed on top of core spring framework. The main concept behind spring boot is to avoid lot of boilerplate code and configuration to improve development, unit test etc.

Spring boot jsp example

Directory Structure

Spring security

pom.xml file

Modify auto created POM file. We need to add parent in pom to make it a spring boot application. After that add spring-boot-starter-web dependency and java version.

<project xmlns="" xmlns:xsi=""
       <!-- This is a web application -->
	<!-- Tomcat embedded container-->
	<!-- JSTL for JSP -->
	<!-- Need this to compile JSP -->
	<!-- Need this to compile JSP -->
			<!-- Package as an executable jar or war -->

Now, right click on project -> click on Maven -> click on update project -> Popup window will open -> click Ok to update the project.
It is a initializer class which runs a SpringApplication.

package com.codesjava;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
public class App extends SpringBootServletInitializer {
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(App.class);
    public static void main( String[] args ) {, args);  

package com.codesjava;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
public class HelloWorldController {
	private String message = "Hello World";
	public String welcome(Map<String, Object> model) {
		model.put("message", this.message);
		return "helloWorld";


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<%@ taglib prefix="spring" uri=""%>
<%@ taglib prefix="c" uri=""%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
	<h2>Spring Boot JSP Hello World Example</h2>
	<h2>Message: ${message}</h2>

spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp

Hit http://localhost:8080/ in the browser, following output will come.
Spring security

Spring Tutorial

Spring framework.
Spring framework architecture.
Spring ioc container.
Spring bean.
Spring bean scopes.
Spring bean life cycle.
Spring callback methods.
Spring hello world.
Spring bean definition inheritance.
Spring bean definition template.
Spring dependency injection.
Spring constructor based injection.
Constructor injection type ambiguities.
Setter based dependency injection.
Spring dependency injection collections.
Spring autowire
Spring autowire by name
Spring autowire by type
Spring autowire by constructor
Spring JDBC tutorial
Spring JDBC Prepared Statement
Spring ResultSetExtractor
Spring RowMapper
Spring aop tutorial.
Spring AOP AspectJ Xml.
Spring AOP AspectJ Annotation.
Spring MVC tutorial.
Spring mvc framework.
Spring mvc configuration file.
Spring mvc hello world.
Spring MVC multiple controller.
Spring MVC login.
Spring mvc form handling.
Spring mvc exception handling.
Spring spel tutorial.
Spring spel hello world.
Spring spel operators.
Spring spel ternary operator.
Spring spel standardevaluationcontext.
Spring spel bean reference.
Spring spel method invocation.
Spring spel list, map.
Spring spel regex.
Maven Eclipse Spring
Spring boot overview
Spring boot architecture diagram
Spring boot components
Spring boot starter parent
Spring boot web app configuration
Run spring boot application
Spring boot change port
Spring boot change context path
Spring boot log sql statements
Spring boot hello world
Spring boot JSP
Spring boot thymeleaf
Spring boot with mysql
Spring security overview
Spring security architecture
Spring security maven dependency
Spring security xml
Spring security annotation
Spring security custom login xml
Spring security custom login annotation
Spring security form login
Spring security remember me
Spring security method level

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki