Results 1 to 2 of 2

Thread: How do you intercept PageNotFound warnings?

  1. #1
    Join Date
    May 2009
    Posts
    246

    Default How do you intercept PageNotFound warnings?

    Hi, I'd like to intercept the PageNotFound warning and send the user to a custom 404 page. How does one do that? Trapping org.springframework.web.servlet.PageNotFound doesn't seem to work.

    Also, I tried adding the following code to my web.xml
    Code:
    	<error-page>
    		<error-code>404</error-code>
    	    <location>/WEB-INF/freemarker/404.ftl</location>
    	</error-page>
    However, tomcat seems to not want to invoke this page when the wrong url is entered for non-spring urls. Help with this too please?

  2. #2
    Join Date
    May 2009
    Posts
    246

    Default

    Nevermind, I fixed it for both. The solution was to change it to:
    Code:
    	<error-page>
    		<error-code>404</error-code>
    	    <location>/404.ftl</location>
    	</error-page>
    IntelliJ is reporting this as an error, but this actually works for both 404 types - spring and regular servlet errors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •