当前位置: 技术问答>java相关
jsp向applet传一个arraylist的问题。
来源: 互联网 发布时间:2015-04-19
本文导语: 我用jsp向applet传一个arraylist,arraylist中存的是数组。 用了ObjectInputStream但报错: java.io.StreamCorruptedException: InputStream does not contain a serialized object at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:849) at java.io...
我用jsp向applet传一个arraylist,arraylist中存的是数组。
用了ObjectInputStream但报错:
java.io.StreamCorruptedException: InputStream does not contain a serialized object at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:849)
at java.io.ObjectInputStream.(ObjectInputStream.java:168)
at untitled3.Applet1.button1_actionPerformed(Applet1.java:160)
at untitled3.Applet1$2.actionPerformed(Applet1.java:83)
at java.awt.Button.processActionEvent(Button.java:329)
at java.awt.Button.processEvent(Button.java:302)
at java.awt.Component.dispatchEventImpl(Component.java:2593)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
怎么解决,怎么才能传arraylist?
用了ObjectInputStream但报错:
java.io.StreamCorruptedException: InputStream does not contain a serialized object at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:849)
at java.io.ObjectInputStream.(ObjectInputStream.java:168)
at untitled3.Applet1.button1_actionPerformed(Applet1.java:160)
at untitled3.Applet1$2.actionPerformed(Applet1.java:83)
at java.awt.Button.processActionEvent(Button.java:329)
at java.awt.Button.processEvent(Button.java:302)
at java.awt.Component.dispatchEventImpl(Component.java:2593)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
怎么解决,怎么才能传arraylist?
|
你存放在arraylist里面的所有类都必须是serialable,
你的类里面的所有成员也都必须是serialable,或者是基本类型
你的类里面的所有成员也都必须是serialable,或者是基本类型
|
在applet的init的方法中建立一个与servlet的URLConnection,并接受servlet的inputstream.
在servlet的doGet方法中,得到一个response的outputstream,写入序列化对象,即继承Serialiable的。
在servlet的doGet方法中,得到一个response的outputstream,写入序列化对象,即继承Serialiable的。
|
而且arraylist是1.2以后才提出的,
建议你用Vector算了
建议你用Vector算了