Reputation: 1631
For example, I have a servlet mapping /servlet, and actually it is requested by a form using POST Method. If I type in the mapping directly without using the form in the browser, the server will give me a 405 page.
HTTP Status 405 - Request method 'GET' not supported
What I want to do is to catch this exception using spring security. I was thinking to restrict this servelet request by using POST method only so that the direct url access will be denied. However, I searched on the internet but I didn't find an answer. Please guide me how to do this, thanks.
Upvotes: 0
Views: 238
Reputation: 993
If you want to override default error message you should create your own error page and map it into web.xml like this
<error-page>
<error-code>405</error-code>
<location>/internal-server-error.htm</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/405.html</location>
</error-page>
and your 405.html will contain your personalized error message for the user.
Read more: http://mrbool.com/how-to-create-error-page-in-j2ee/26770
Upvotes: 1