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?

Comment From: NadChel

Adding a webapp directory and moving my JSPs there helped. More info on that here

Comment From: wilkinsona

I'm glad to hear you worked it out. FYI, src/main/webapp is the standard location for JSPs, particularly when using Maven and its war plugin.

While I'm here, these dependencies look incorrect to me:


<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>

Spring Boot 3.0 requires Servlet 5.0 or later.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Comment From: NadChel

I'm glad to hear you worked it out. FYI, src/main/webapp is the standard location for JSPs, particularly when using Maven and its war plugin.

While I'm here, these dependencies look incorrect to me:

```

javax.servlet javax.servlet-api 3.1.0 provided

javax.servlet jstl 1.2 ```

Spring Boot 3.0 requires Servlet 5.0 or later.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Have you considered changing this? It seems unfair that I have to provide this additional directory instead of just storing my views in the templates directory as HTML folks do

2023-03-24_10-49-31

Comment From: wilkinsona

We don't have any plans to change it. As I mentioned above, it's a standard location for war development.

Comment From: Vcalendar

@wilkinsona https://tankauth-playful65.github.io/OuB2xLpsInu0hU532JU40Hc4GzF09W18AjeU4sYp310wDQFgOEFL0P/