public InputStream readFile(String path) {
File file = new File(path);
try {
return FileUtils.openInputStream(file);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
以上是我的代码,我箱把catch()中的e信息显示到页面上怎么处理?在线等!file,异常

解决方案 »

  1.   

    request.setattribute...试试?
      

  2.   


    PrintWriter pWriter = new PrintWriter(new CharArrayWriter());
    e.printStackTrace(pWriter);//重定向到writer中
    String exceptionInfo = pWriter.toString();
    response.getWriter.println(exceptionInfo);//写到jsp页面
      

  3.   

    是显示在页面给用户看?如果是异常拦截,在web.xml中可以配置,详细信息用log4j记录,不用给用户看错误代码...,
           <!-- 定义错误页面 -->
    <error-page>
      <exception-type>com.ecp.util.ApplicationException</exception-type>
      <location>/system_error.jsp</location>
    </error-page>

    <error-page>
    <error-code>404</error-code>
    <location>/http_error404.jsp</location>
    </error-page>

    <error-page>
    <error-code>500</error-code>
    <location>/http_error505.jsp</location>
    </error-page>