Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring Boot Thymeleaf Whitelabel Error Page

I have an apllication using spring boot 2.7.1, when i type the address http://localhost:9096/popup/111111, I get the below response:

Whitelabel Error Page This application has no explicit mapping for
/error, so you are seeing this as a fallback.

Tue Aug 02 12:20:32 CET 2022 There was an unexpected error (type=Not
Found, status=404).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
    <groupId>nz.net.ultraq.thymeleaf</groupId>
    <artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>

application.yml

server:
  port: 9096

spring:
  thymeleaf:
    cache: false
    enabled: true
    mode: HTML5
    prefix: /templates/
    suffix: .html

controller:

@Controller("popup")
public class PopupRequest {

    @GetMapping("/{requestNumber}")
    String index(@PathVariable("requestNumber") String requestNumber) {
        return "index";
    }
}

>Solution :

Try adding @RequestMapping("/popup") as an annotation to the class like so:

@Controller
@RequestMapping("/popup")
public class PopupRequest {

    @GetMapping("/{requestNumber}")
    String index(@PathVariable("requestNumber") String requestNumber) {
        return "index";
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading