//发送一个请求,并发送一个对象过去,获得一个返回的对象
public Object sendRequest(URL url, Object object) {
Object o = null;
try {
URLConnection con = url.openConnection();
System.out.println("111111111111111111111 " + url);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProperty("Content-Type",
"application/x-java-serialized-object"); ObjectOutputStream out = new ObjectOutputStream(con
.getOutputStream());
System.out.println("22222222222222222222 " + url);
out.writeObject(object);
out.flush();
out.close(); InputStream in = con.getInputStream();
System.out.println("33333333333333333333 " + in.toString());
ObjectInputStream objStream;
objStream = new ObjectInputStream(in);
o = objStream.readObject();
System.out.println("44444444444444444444 " + url);
} catch (Exception e) {
System.out.println("sendRequest(URL url,Object object) --------------------error !");
System.err.println(e.toString());
}
return o;
}
在o = objStream.readObject();抛出IE异常。
说明,改程序在weblogic服务器中执行正常。

解决方案 »

  1.   

    更正一下
    在o = objStream.readObject();抛出IO异常。 
      

  2.   

    java.io.IOException: Server returned HTTP response code: 505 for URL: http://192.168.1.200:9080/servlet/BusModuleServlet?Action=searchList&Where=C_Module_ID like '{C{'
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.git.loan.config.business.busmodule.BusModuleMainFrame.getBusinessList(Unknown Source)
    at com.git.loan.config.business.busmodule.BusModuleMainFrame.refreshData(Unknown Source)
    at com.git.loan.config.business.busmodule.BusModuleMainFrame.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    这个异常是因为http地址传输的过程中有空格,替换掉后同样的捕获,打出的异常为java.io.EOFException
    没有其他的信息。
      

  3.   

    Server returned HTTP response code: 505 for URL505 - HTTP 版本不受支持,我猜测可能是下面的某个属性没有被支持con.setUseCaches(false); 
    con.setDoInput(true); 
    con.setDoOutput(true); 
    con.setRequestProperty("Content-Type", 
    "application/x-java-serialized-object");
    尤其是红色部分不知道是什么属性,没有见过