I am working with tomcat 7 and I've built and deployed a Spring MVC webapp in tomcat 7 and it's working perfectly fine. What I want is that, whenever a 404 error occurs on my server, it should be redirected to a custom page which I have built in my webapp. I have configured my webapp as a default webapp in tomcat.
I have tried doing this:
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/templates/error/error.html</location>
</error-page>
But all in vain.
Glad if someone can help me out in this.
You can do something like this:
<error-page>
<error-code>404</error-code>
<location>error404</location>
</error-page>
And then:
@Controller
public class ErrorController {
@RequestMapping("/error404")
protected String error404() {
return "/templates/error/error.html";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With