关于异常的疑问??????
代码如下:
-----------------
try
{
......
} catch (
java.net.SocketException se)
{
System.out.println( "SectionPicture:27: " + se.getMessage());
} catch (Exception exception)
{
System.out.println( "SectionPicture:30: " + exception.getMessage());
exception.printStackTrace();
}
显示出异常如下:
----------------
SectionPicture:30:null
Client
AbortException: java.net.
SocketException: Connection reset by peer: socke
t write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffe
r.java:366)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:353)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.ja
va:392)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:38
1)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputSt
ream.java:88)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputSt
ream.java:82)
....
我的主为,应该显示
SectionPicture:27 ....
为什么,java.net.SocketException未能捕捉到ClientAbortException: java.net.SocketException: Connection reset by peer: socke
t write error
------解决方案--------------------catch (java.net.SocketException se)
改为
catch (SocketException se)
试试
------解决方案--------------------ClientAbortException是什么东西?没有用过
也许ClientAbortException封装了SocketException,TRY块中抛的异常是ClientAbortException,ClientAbortException不是SocketException的子类(或许是父类,又或许聚合了SocketException),所以才无法CATCH SocketException
你试一下,catch (java.net.ClientAbortException e)就能捕到
------解决方案--------------------ClientAbortException 这是客户端中断了输出流,如下载文件的中途关闭窗口,就会报这个异常,或者页面还没有显示出来,客户端刷新页面也会报这个错误
------解决方案--------------------学习
------解决方案--------------------学习
------解决方案--------------------e.getClass().getName()
看看究竟是什么异常