从安全的角度来看,使用 Websphere 处理应用程序错误的最佳解决方案是什么?
我一直在考虑创建一个每次生成应用程序错误时调用的类,记录错误并向用户显示一般错误消息。
在 PHP 中,这可以使用 set_exception_handler() 函数来实现。是否有类似的 websphere 可以在 web.xml 中配置?
我在网上找到了这样的代码:
<error-page>
<error-code>500</error-code>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>
但这仅适用于“500”HTTP 错误代码。我真的想要一些通用的东西来捕捉一切。类似于实现某个接口(interface)的类,该接口(interface)可以访问有关错误的所有信息。
谢谢你的时间。
最佳答案
这在 web.xml 中也可用:
<error-page>
<exception-type>UnhandledException</exception-type>
<location>UnhandledException.jsp</location>
</error-page>
在其他地方,这用于this WebSphere example . JEE5 教程也可能有助于设置它,尤其是关于 mapping servlet exceptions 的部分和 creating JSP error pages .
本质上,您所有的异常都应该包含在 ServletExceptions 中。你映射到的 JSP 应该有
<%@ page isErrorPage="true" %>
设置在页面的最顶部。
关于security - Websphere 异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2581942/