我明白为什么 HttpServlet 会抛出 ServletException,但为什么会抛出 IOException?这背后的原因是什么?
最佳答案
来自文档:
IOException - if an input or output error is detected when the servlet handles the GET request
当您打印 servlet 输出时,可能会发生这种情况:
response.getWriter().print() - 此方法抛出 IOException
可以在响应完成打印输出之前关闭套接字。
关于java - 为什么 HttpServlet 会抛出 IOException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/802967/