Raghav
Raghav

Reputation: 1064

Request for a non existent page results in blank page in Spring web application

Am using a Spring web application. Have used an ExceptionHandler for trapping all the exceptions in my application. However, when an error occurs such as 404, the default tomcat server error message was getting displayed.

So I added the below code

   <error-page> 
        <error-code>404</error-code>  
        <location>/errorPage.html</location>      
   </error-page>

in my web.xml.

Now when I try to access a non-existing page, am getting a blank page in Firefox. When debugging with Firebug, I noticed only response headers are getting passed back and no response content is visible.

In IE, it is displaying browser's default 404 page.

What am I missing here?

Upvotes: 0

Views: 1316

Answers (2)

Keshav
Keshav

Reputation: 831

The 404 error code is configured properly, but it will caused the “.htm” extension handling conflict between the “servlet container” and Spring’s “DispatcherServlet“. To solve it, try change the 404.htm to other file extension, for example 404.jsp.

For more details you can visit this link http://www.mkyong.com/spring-mvc/404-error-code-is-not-working-in-spring-mvc/

Upvotes: 1

Raghav
Raghav

Reputation: 1064

Interestingly, when I changed my errorPage.html to errorPage.jsp it worked fine. I left the other configuration unchanged and only changed this. Still dont know why this was happening. Will try to find out during the weekend.

Thanks for the responses.

Upvotes: 0

Related Questions