spring boot webpage with gradle dependencies not opening jsp files

224 views Asked by At

I don't see any prevailing errors with my code and the configuration and dependancies should all be correct, however when I search in the url the console outputs this:

"Path with "WEB-INF" or "META-INF": [WEB-INF/views/login.jsp]"

rather than opening the jsp file.

Does anyone why this is happening?

This is the structure of my folders within the project

Controller:

package com.example.mywebsite.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {

    @RequestMapping("/")
    public String start(){
        return "login";
    }

}

Configuration:

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

build.gradle:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'org.springframework.boot:spring-boot-starter-validation'

    runtimeOnly 'org.apache.tomcat.embed:tomcat-embed-jasper:9.0.41' // JSPs
    runtimeOnly 'javax.servlet:jstl:1.2' // helpful JSP tags

    runtimeOnly 'mysql:mysql-connector-java' //connect to sql
}

login.jsp:

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


<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login</title>
</head>
<body>
<h1>Login</h1>

</body>
</html>
1

There are 1 answers

3
Reddi Kalyan On

Try to remove the version number from tomcat jasper dependency in build.gradle fie.

For more details check the comments under this post