我有一个使用spring 2.7.1的应用程序,当我输入address http://localhost:9096/popup/111111时,我会得到以下响应:
白线错误页此应用程序没有/error的显式映射,因此您认为这是一种退步。
星期二8月12:20:32 CET 2022有一个意外的错误(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("popup")
public class PopupRequest {
@GetMapping("/{requestNumber}")
String index(@PathVariable("requestNumber") String requestNumber) {
return "index";
}
}发布于 2022-08-02 11:50:39
尝试添加@RequestMapping("/popup")作为类的注释,如下所示:
@Controller
@RequestMapping("/popup")
public class PopupRequest {
@GetMapping("/{requestNumber}")
String index(@PathVariable("requestNumber") String requestNumber) {
return "index";
}
}发布于 2022-08-02 12:04:38
您必须用括号("/")关闭请求映射。
Controller
@RequestMapping("/popup")
public class PopupRequest {
@GetMapping("/{requestNumber}")
String index(@PathVariable("requestNumber")String r requestNumber){
return "index";
}
}https://stackoverflow.com/questions/73206905
复制相似问题