JAVA如何隐藏异常堆栈_java – 如何在控制台上停止打印异常堆栈跟踪?
這是我做的這樣的戰爭作為工作。
添加一個過濾器并劫持所有的請求和響應。檢查異常并檢查類型。
/**
* Hijacks all the http request and response here.
* Catch the SocketException and do not print
* If other exceptions print to console
* date : 9-18-2013
*
* @author Suresh Atta
*
*/
public class ExceptionHandler implements Filter {
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
try{
arg2.doFilter(arg0, arg1);
}catch(SocketException e ){
// Please don't print this to log.
}
}
}
而在web.xml中,過濾器映射
ExceptionHandler
com.nextenders.server.ExceptionHandler
ExceptionHandler
REQUEST
/*
我沒有把這標記為答案,因為我不知道這是一個標準的方式。
總結
以上是生活随笔為你收集整理的JAVA如何隐藏异常堆栈_java – 如何在控制台上停止打印异常堆栈跟踪?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求链表相交时的交点(C语言)
- 下一篇: dos c语言显示符号图案,在DOS命令