Search code examples
javaspring-booteclipsetomcatintellij-idea

Jsp not found. status=404 : Whitelabel Error Page. ResourceHttpRequestHandler : "Path with "WEB-INF" or "META-INF": [WEB-INF/jsps/CreateLocation.jsp]"


I'm facing the problem with accessing the jsp page in SpringBoot application.

Getting the bellow error.

o.s.w.s.r.ResourceHttpRequestHandler : "Path with "WEB-INF" or "META-INF": [WEB-INF/jsps/CreateLocation.jsp]"

Tried to change the WEB-INF folder to different locations. Didn't work.

Any new folder structure for Springboot v3.1.0

I tried all the given options which is mentioned in previous questions.

Link 1

Link 2

Link 3

But didn't work.

Below I have given the detailed flow structure and image for reference.

Controller Class

@Controller
@RequestMapping("LocCon")
public class LocationController
{
    @GetMapping("/ShowCreate")
    public String showCreate()
    {
        return "CreateLocation";
    }
}

application.properties

# For jsp view
spring.mvc.view.prefix=/WEB-INF/jsps/
spring.mvc.view.suffix=.jsp
server.servlet.register-default-servlet=true

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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.sarath.location</groupId>
    <artifactId>LocationWeb</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>LocationWeb</name>
    <description>LocationWeb</description>
    <properties>
        <java.version>20</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </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-actuator</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        -->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Folder Structure

├───LocationWeb
│   ├───.mvn
│   │   └───wrapper
│   ├───src
│   │   ├───main
│   │   │   ├───java
│   │   │   │   └───com
│   │   │   │       └───sarath
│   │   │   │           └───location
│   │   │   │               ├───controller
│   │   │   │               ├───entities
│   │   │   │               ├───repository
│   │   │   │               └───service
│   │   │   ├───resources
│   │   │   │   ├───static
│   │   │   │   └───templates
│   │   │   └───webapp
│   │   │       └───WEB-INF
│   │   │           └───jsps
│   │   └───test
│   │       └───java
│   │           └───com
│   │               └───sarath
│   │                   └───location

enter image description here


Solution

  • Tried the same project in eclipse. Works good. No issues. Only facing that in intellij. Didn't change anything. Just imported and tried.

    enter image description here