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).
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";
}
}
CodePudding user response:
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";
}
}
CodePudding user response:
//
You must inclose request mapping with
parenthesis ("/")
//
Controller
@RequestMapping("/popup")
public class PopupRequest {
@GetMapping("/{requestNumber}")
String index(@PathVariable("requestNumber"String r requestNumber) {
return "index";
}
}