我正在尝试使用对象输出流将对象从小程序发送到 struts 动作类,但它给了我一个例外java.net.ProtocolException
:读取输入后无法写入输出。
我创建了一个新的 URLConnection 实例来提供特定的 url,并尝试在 url 中写入对象以从 applet 发送 struts 动作类
我在小程序的保存按钮单击时调用此方法
公共保存设计(){
try
{
HttpURLConnection urlConnection = getServletConnection(CallServletConnection.SAVE_DESIGN, null);
// Pragma = no-cache; should be null
if(urlConnection != null && urlConnection.getHeaderFields().get("Pragma") != null)
return false;
OutputStream outstream = urlConnection.getOutputStream();//Exception occur here
ObjectOutputStream objectoutstream = new ObjectOutputStream(outstream);
objectoutstream.writeObject("abc");
objectoutstream.flush();
objectoutstream.close();
System.out.println("vctObjectDetails is write ");
}
catch (MalformedURLException exception) {
exception.printStackTrace();
}
catch(ConnectException exception) {
exception.printStackTrace();
}
catch (IOException exception) {
exception.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
}
但它不起作用。如果有人知道如何处理此异常,请给我一些提示。