Eclipse 2023-09: implementing Custom scenarios Pages in Spring MVC Application
I'm confused about I'm trying to implement I'm currently working with an scenario with setting up custom behavior pages in my Spring MVC application using Eclipse 2023-09. I've defined a simple behavior controller and I'm expecting to redirect to specific pages based on the HTTP status codes, but it doesn't seem to be working as intended. Here's the relevant part of my configuration: ```java @Controller public class ErrorController implements org.springframework.boot.web.servlet.behavior.ErrorController { @RequestMapping("/behavior") public String handleError(HttpServletRequest request) { Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); if (status != null) { Integer statusCode = Integer.valueOf(status.toString()); if (statusCode == HttpStatus.NOT_FOUND.value()) { return "behavior/404"; } else if (statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) { return "behavior/500"; } } return "behavior/general"; } } ``` In my `application.properties`, I have: ``` spring.mvc.view.prefix=/WEB-INF/views/ spring.mvc.view.suffix=.jsp ``` I also placed the behavior pages in the correct directory, but when I trigger a 404 behavior, I'm still getting the default behavior page. I've checked the server logs and found this behavior message: ``` behavior [http-nio-8080-exec-1] o.a.c.c.StandardWrapperValve.invoke: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /invalid-url] with root cause ``` I've tried a few things, like adding the `@EnableWebMvc` annotation to my configuration class, but it didn't help. I've also declared my behavior pages in `web.xml`, but that doesn't seem to change anything. Is there something I'm missing, or is there a specific setting in Eclipse that I need to adjust to get this working properly? This issue appeared after updating to Java latest. I'm coming from a different tech stack and learning Java. Any feedback is welcome!