Spring boot Jsp file not found












1















enter image description here



Spring boot is not able to find the jsp file in the application. I do not know why it is not able to find the jsp file in the given path. Can you please let me know how to resolve it



SpringBootHelloWorldApplication.java



import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHelloWorldApplication {

public static void main(String args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
}


WelcomeController.java



@Controller
public class WelcomeController {

@RequestMapping("/hello")
public String getHello(Model model){
model.addAttribute("message", "welcome to the jsp page");
return "welcome";
}
}


application.properties



spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp


welcome.jsp



<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html lang="en">

<body>Message: ${message}
</body>
</html>


pom.xml



    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot.application</groupId>
<artifactId>springbootmvc2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springbootmvc2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
</project>









share|improve this question

























  • location of welcome.jsp? also attach screenshot of directory structure.

    – Alien
    Nov 14 '18 at 4:29













  • I attached directory structure

    – user3094331
    Nov 14 '18 at 4:32











  • Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

    – N00b Pr0grammer
    Nov 14 '18 at 4:38













  • I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

    – user3094331
    Nov 14 '18 at 4:42













  • @user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

    – Ankur Singhal
    Nov 14 '18 at 4:42
















1















enter image description here



Spring boot is not able to find the jsp file in the application. I do not know why it is not able to find the jsp file in the given path. Can you please let me know how to resolve it



SpringBootHelloWorldApplication.java



import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHelloWorldApplication {

public static void main(String args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
}


WelcomeController.java



@Controller
public class WelcomeController {

@RequestMapping("/hello")
public String getHello(Model model){
model.addAttribute("message", "welcome to the jsp page");
return "welcome";
}
}


application.properties



spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp


welcome.jsp



<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html lang="en">

<body>Message: ${message}
</body>
</html>


pom.xml



    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot.application</groupId>
<artifactId>springbootmvc2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springbootmvc2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
</project>









share|improve this question

























  • location of welcome.jsp? also attach screenshot of directory structure.

    – Alien
    Nov 14 '18 at 4:29













  • I attached directory structure

    – user3094331
    Nov 14 '18 at 4:32











  • Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

    – N00b Pr0grammer
    Nov 14 '18 at 4:38













  • I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

    – user3094331
    Nov 14 '18 at 4:42













  • @user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

    – Ankur Singhal
    Nov 14 '18 at 4:42














1












1








1








enter image description here



Spring boot is not able to find the jsp file in the application. I do not know why it is not able to find the jsp file in the given path. Can you please let me know how to resolve it



SpringBootHelloWorldApplication.java



import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHelloWorldApplication {

public static void main(String args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
}


WelcomeController.java



@Controller
public class WelcomeController {

@RequestMapping("/hello")
public String getHello(Model model){
model.addAttribute("message", "welcome to the jsp page");
return "welcome";
}
}


application.properties



spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp


welcome.jsp



<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html lang="en">

<body>Message: ${message}
</body>
</html>


pom.xml



    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot.application</groupId>
<artifactId>springbootmvc2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springbootmvc2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
</project>









share|improve this question
















enter image description here



Spring boot is not able to find the jsp file in the application. I do not know why it is not able to find the jsp file in the given path. Can you please let me know how to resolve it



SpringBootHelloWorldApplication.java



import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHelloWorldApplication {

public static void main(String args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
}


WelcomeController.java



@Controller
public class WelcomeController {

@RequestMapping("/hello")
public String getHello(Model model){
model.addAttribute("message", "welcome to the jsp page");
return "welcome";
}
}


application.properties



spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp


welcome.jsp



<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html lang="en">

<body>Message: ${message}
</body>
</html>


pom.xml



    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot.application</groupId>
<artifactId>springbootmvc2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springbootmvc2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
</project>






java spring spring-mvc jsp spring-boot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 7:30







user3094331

















asked Nov 14 '18 at 4:27









user3094331user3094331

12710




12710













  • location of welcome.jsp? also attach screenshot of directory structure.

    – Alien
    Nov 14 '18 at 4:29













  • I attached directory structure

    – user3094331
    Nov 14 '18 at 4:32











  • Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

    – N00b Pr0grammer
    Nov 14 '18 at 4:38













  • I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

    – user3094331
    Nov 14 '18 at 4:42













  • @user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

    – Ankur Singhal
    Nov 14 '18 at 4:42



















  • location of welcome.jsp? also attach screenshot of directory structure.

    – Alien
    Nov 14 '18 at 4:29













  • I attached directory structure

    – user3094331
    Nov 14 '18 at 4:32











  • Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

    – N00b Pr0grammer
    Nov 14 '18 at 4:38













  • I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

    – user3094331
    Nov 14 '18 at 4:42













  • @user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

    – Ankur Singhal
    Nov 14 '18 at 4:42

















location of welcome.jsp? also attach screenshot of directory structure.

– Alien
Nov 14 '18 at 4:29







location of welcome.jsp? also attach screenshot of directory structure.

– Alien
Nov 14 '18 at 4:29















I attached directory structure

– user3094331
Nov 14 '18 at 4:32





I attached directory structure

– user3094331
Nov 14 '18 at 4:32













Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

– N00b Pr0grammer
Nov 14 '18 at 4:38







Can you make the spring-boot-starter-tomcat scope changed to provided instead of the default compile scope and check?

– N00b Pr0grammer
Nov 14 '18 at 4:38















I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

– user3094331
Nov 14 '18 at 4:42







I changed to provided. I am getting the below error Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Nov 14 10:12:15 IST 2018 There was an unexpected error (type=Not Found, status=404). No message available

– user3094331
Nov 14 '18 at 4:42















@user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

– Ankur Singhal
Nov 14 '18 at 4:42





@user3094331 Is your controller called, have you checked that, what is the exact error, also what annotations have you put on SpringBootHelloWorldApplication class, can you post this class complete.

– Ankur Singhal
Nov 14 '18 at 4:42












1 Answer
1






active

oldest

votes


















1














You are missing @SpringBootApplication annotation on main class.



Here is a working example : Spring-Boot-Jsp-Demo






share|improve this answer
























  • He has already mentioned it!

    – Varun Jain
    Nov 14 '18 at 12:46






  • 1





    @VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

    – Alien
    Nov 14 '18 at 12:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293194%2fspring-boot-jsp-file-not-found%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You are missing @SpringBootApplication annotation on main class.



Here is a working example : Spring-Boot-Jsp-Demo






share|improve this answer
























  • He has already mentioned it!

    – Varun Jain
    Nov 14 '18 at 12:46






  • 1





    @VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

    – Alien
    Nov 14 '18 at 12:48
















1














You are missing @SpringBootApplication annotation on main class.



Here is a working example : Spring-Boot-Jsp-Demo






share|improve this answer
























  • He has already mentioned it!

    – Varun Jain
    Nov 14 '18 at 12:46






  • 1





    @VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

    – Alien
    Nov 14 '18 at 12:48














1












1








1







You are missing @SpringBootApplication annotation on main class.



Here is a working example : Spring-Boot-Jsp-Demo






share|improve this answer













You are missing @SpringBootApplication annotation on main class.



Here is a working example : Spring-Boot-Jsp-Demo







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 7:04









AlienAlien

4,91331026




4,91331026













  • He has already mentioned it!

    – Varun Jain
    Nov 14 '18 at 12:46






  • 1





    @VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

    – Alien
    Nov 14 '18 at 12:48



















  • He has already mentioned it!

    – Varun Jain
    Nov 14 '18 at 12:46






  • 1





    @VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

    – Alien
    Nov 14 '18 at 12:48

















He has already mentioned it!

– Varun Jain
Nov 14 '18 at 12:46





He has already mentioned it!

– Varun Jain
Nov 14 '18 at 12:46




1




1





@VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

– Alien
Nov 14 '18 at 12:48





@VarunJain can you see the timings of my answer and his edit answer..i posted this after that he edited the question.

– Alien
Nov 14 '18 at 12:48


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293194%2fspring-boot-jsp-file-not-found%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine