我使用Java配置,而不是web.хml
我已添加到application.properties
server.error.whitelabel.enabled=false
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
并创建控制器
@Controller
public class MyErrorController implements ErrorController {
@RequestMapping("/error")
public String handleError() {
//do something like logging
return "error404";
}
@Override
public String getErrorPath() {
return "/error";
}
}
我使用了本教程https://www.baeldung.com/spring-boot-custom-error-page
这不起作用,您能帮我吗?