cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

error page mapping not working

0 Likes
541

Hi, I'm trying to set custom error page for 500 response. I've set it like this:

 <error-page>
         <error-code>500</error-code>
         <location>/WEB-INF/views/desktop/pages/error/error.jsp</location>
     </error-page>

But it's not working for using not supported request type, I'm still getting error page with stack trace with exception org.springframework.web.HttpRequestMethodNotSupportedException. I also tried to set exception-type to java.lang.Exception, but it's not working either. How can it be set to make it work? Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

andyfletcher
Active Contributor
0 Likes

It's not a 500 error but rather a 405 Method Not Allowed

Just add another <error-page> for 405 errors

e.g.

 <error-page>
      <error-code>405</error-code>
      <location>/WEB-INF/common/pages/error/serverError.jsp</location>
 </error-page>

You can test it with something like

 curl -ik -XPUT https://powertools.local:9002/ | head -n 1

e.g.

 $ curl -ik -XPUT https://powertools.local:9002/ | head -n 1
 HTTP/1.1 405 Method Not Allowed

Just replace with your correct hostname or you'll get a 500 error because there's no matching url pattern

0 Likes

Thanks for reply. I tried to set it for 405 too, but it's still the same error. It looks like it should be 405, but finally on the output it's shown as 500 response

andyfletcher
Active Contributor
0 Likes

Then presumably there is some other error happening whilst rendering the page for the 405 response. You should check your console log for a clue to where the problem is.