这是我做的这样的战争作为工作。
添加一个过滤器并劫持所有的请求和响应。检查异常并检查类型。
/**
* 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
/*
我没有把这标记为答案,因为我不知道这是一个标准的方式。