The constructor for ObjectInputStream reads some header
information from the serialized stream, and if the stream doesn't contain this
header information you could easily get an EOFException. This is what I do in
my service() method:
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
if ( request.getContentLength() > 0 &&
"application/octet-stream".equals(request.getContentType())) {
ObjectInputStream inputStream =
new ObjectInputStream(request.getInputStream());
even this only provides limited protection.
本文探讨了在使用ObjectInputStream读取序列化流时可能遇到的EOFException问题,并提供了一种检查请求内容类型和长度的方法来初步解决问题。
2296

被折叠的 条评论
为什么被折叠?



