且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用JAVA处理REST API中的内部服务器错误?

更新时间:2023-09-11 09:09:52

我不知道您使用的是哪种Web服务器,但是只要它符合 JEE规范,您就可以在您的 web.xml :

I don't know what webserver you are using, but as long as it adheres to JEE specs you could simply handle it in your web.xml:

<错误页面>
   <错误代码> 500</错误代码>
   < location>/path/to/myErrorPage.html</location>
</error-page>

<error-page>
    <error-code>500</error-code>
    <location>/path/to/myErrorPage.html</location>
</error-page>