Skip to content

"Whitelabel Error Page 404 Not Found" when trying to access a JSP view. Why is that (yes, I did specify the WAR packaging) #34730

@NadChel

Description

@NadChel

Hi. When sending a request from my browser, which is a basic http://localhost:8080/, I get a 404 error instead of my jsp view. It's unexpected since, it seems, I got my pom and properties right. I have these dependencies (among others)

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.4</version>
        <relativePath/>
    </parent>
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</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>compile</scope>
        </dependency>
        
                <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

and these properties

spring.mvc.view.prefix=classpath:/templates/
spring.mvc.view.suffix= .jsp
spring.mvc.servlet.path= /
server.servlet.register-default-servlet=true

The request is also handled by my controller class

@Controller
public class MyController {
    private final UserService userService;

    public MyController(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/")
    public String showUsers(Model model) {
        // ...
        return "index";
    }

In case this information is insufficient, here's the repo.

I hope my post doesn't violate any guidelines. I've already read this post (as well as quite a few StackOverflow questions) so I do use the war packaging. I compiled the project using Maven afterwards

<groupId>my_pp</groupId>
    <artifactId>CRUD_user_boot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>CRUD_user_boot</name>
    <description>CRUD_user_boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>

Could you tell me what's wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions