查看接口
ServletRequest的源码
public
ServletInputStream getInputStream()
throws
IOException;
request.getInputStream()返回的其实是ServletInputStream。
ServletInputStream继承了InputStream
但是没有重写reset()方法。
InputStream
的
reset()方法源码是这样的:
public
synchronized
void
reset()
throws
IOException {
throw
new
IOException(
"mark/reset not supported"
);
}
调用reset方法直接抛出异常,所以ServletInputStream是不能调用reset方法,这就导致了只能调用一次getInputStream(),第二次调用的时候没有办法获取到InputStream流中的原因