From ac7354648f4c7413f3ec7e9d72488b7f4acd7da5 Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Sun, 10 Jul 2022 15:27:33 +0300 Subject: [PATCH 1/2] JAVA-13222 --- .../boot/jsp/SpringBootJspApplication.java | 2 ++ .../boot/jsp/controller/HomeController.java | 15 +++++++++++++++ .../src/main/webapp/WEB-INF/jsp/index.jsp | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/HomeController.java create mode 100644 spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java b/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java index c77554f9f6..98122bed50 100644 --- a/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java +++ b/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/SpringBootJspApplication.java @@ -8,6 +8,8 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer @SpringBootApplication(scanBasePackages = "com.baeldung.boot.jsp") public class SpringBootJspApplication extends SpringBootServletInitializer { + + //comment below if deploying outside web container --> @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(SpringBootJspApplication.class); diff --git a/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/HomeController.java b/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/HomeController.java new file mode 100644 index 0000000000..7d7b9c3cbd --- /dev/null +++ b/spring-boot-modules/spring-boot-jsp/src/main/java/com/baeldung/boot/jsp/controller/HomeController.java @@ -0,0 +1,15 @@ +package com.baeldung.boot.jsp.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/") +public class HomeController { + + @GetMapping("") + public String index() { + return "index"; + } +} diff --git a/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp new file mode 100644 index 0000000000..eb797ad297 --- /dev/null +++ b/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp @@ -0,0 +1,10 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + View Books + + +
This is index page
+ + \ No newline at end of file From 56e012d8f6adf540bb3923082a556cc183cc6010 Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Sun, 10 Jul 2022 15:32:55 +0300 Subject: [PATCH 2/2] small fix --- .../spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp index eb797ad297..87b6beaf26 100644 --- a/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/spring-boot-modules/spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp @@ -2,7 +2,7 @@ <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - View Books + Index page
This is index page