Spring boot doesn’t identify html templates without Thymeleaf dependency



I am using spring-boot 2.5.0 and maven as dependency management tool. I have following dependencies as of now in my project.

"<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>"

I want to use jsp instead of thymeleaf but when I put my “index.html” file inside templates or static sub-folder of resources folder it doesn’t recognize the html file and throws white label error.When I added the thymeleaf dependency it worked perfectly and recognized the html file. So, what should I do to make spring-boot detect my html file without adding thymeleaf dependency. By the way I have never used jsp before.

Answer

It seems you are missing either of the two things.

  1. you should put below the property with the desired value in the property/yaml file

    spring.mvc.view.prefix: <location of html/jsp>
    spring.mvc.view.suffix: <.extension>

  2. check at your controller whether you are sending the correct view name or not.



Source: stackoverflow