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