有一个老系统可以用URL这样登录http://www.test.com/login?username=admin&pwd=123
我在现在开发的系统中要怎样登录这个系统呢?我不想用直接跳传的方式登录!
请高人指点!

解决方案 »

  1.   

    用ajax或者异步提交可以考虑一下
      

  2.   


    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;public class Test1 {
        private static String getStaticPage(String surl) {
            String htmlContent = "";
            try {
                java.io.InputStream inputStream;
                java.net.URL url = new java.net.URL(surl);
                java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url
                        .openConnection();
                connection.connect();
                inputStream = connection.getInputStream();
                byte[] bytes = new byte[1024 * 2000];
                int index = 0;
                int count = inputStream.read(bytes, index, 1024 * 2000);
                while (count != -1) {
                    index += count;
                    count = inputStream.read(bytes, index, 1);
                }
                htmlContent = new String(bytes, "UTF-8");
                connection.disconnect();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return htmlContent.trim();
        }    public static void main(String[] args) {
            try {
                String src = getStaticPage("http://www.google.com");
                File file = new File("d:\\aa.html");
                FileWriter resultFile = new FileWriter(file);
                PrintWriter myFile = new PrintWriter(resultFile);// 写文件
                myFile.println(src);
                resultFile.close();
                myFile.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    HttpURLConnection,或者HttpClient
      

  3.   

    httpclient后台处理
    可以考虑下
      

  4.   

    http://www.iteye.com/topic/638206
      

  5.   

    你原来的老系统是用什么开发的,如果有源码的话,可以在原来的老系统嫁接个webService做为一个接口,再在现在开发的系统做个客户端,想怎么调就怎么调,用Xfire、cxf就可以的
      

  6.   


    同意。或者http。你那个是啥系统,真慢
      

  7.   

    哈哈,朋友们我发的那个地址是一个假的,只是做为比喻的。
    我使用过httpClient,登录成功并已经可以获取header中的Set-Cookie,但是当我在地址栏输入老系统还是须要登录!
      

  8.   

    你在server端取得了cookie值,也得设置到前端才行啊。 response set cookies。
    当然,如果涉及到cross domain,set cookie 可能也有问题。你gg一下 单点登录, 解决方式非常多。按照你说的:有一个老系统可以用URL这样登录http://www.test.com/login?username=admin&pwd=123。如果 访问这个链接了,就可以访问老系统的其他保护页面,那么,最简单的方式:在你的新系统页面放这么一段:<iframe width=0 height=0 src="http://www.test.com/login?username=admin&pwd=123"/>
      

  9.   

    <iframe width=0 height=0 src="http://www.test.com/login?username=admin&pwd=123"/>
    这个不错,我以前就用过,不过是在一个系统(A)中引用另外的一个系统(B)的页面,B系统设有过滤器,打开B系统的页面时总跳转到登录页面,所以我就采用这种方式先登录B系统。