request.getInputStream() 和 request.getReader()不能同时调用,否则会引发java.lang.IllegalStateException异常。
API中有写:
getInputStream
public ServletInputStream getInputStream()
throws java.io.IOException
- Retrieves the body of the request as binary data using a
ServletInputStream
. Either this method or getReader()
may be called to read the body, not both.
-
- Returns:
- a
ServletInputStream
object containing the body of the request
- Throws:
java.lang.IllegalStateException
- if the getReader()
method has already been called for this request
java.io.IOException
- if an input or output exception occurred