需求是从本系统登陆到其他系统,页面会列出可以登陆的外部系统点击后一个系统后,我会首先拼出登陆用的url获得url的action
public String execute()
    {
        setUrl(getUrl(getName()));
        return "1_5";
    }private String url;
get()&set()
struts-config.xml
<action name="Bg1_5" class="cms.Bg1_5">
<result name="1_5">?????</result>
</action>我的问题时得到了url后如何跳转到另一个系统,一开始我用了redirect跳转,但是不是本应用的系统不能这样跳转
那么应该如何做呢?

解决方案 »

  1.   

    public String execute()
        {
            ServletActionContext.getResponse().sendRedirect(url);
            return null;
        }
      

  2.   

    <action name="Bg1_5" class="cms.Bg1_5">
                <result name="1_5">{url}</result>
            </action>
      

  3.   

    修改你提交的form,增加属性<form target="_top" ...>
      

  4.   

    这就是技巧性的东西了。
    我相信你用过html的自动跳转(meta标签)或者是jsp自动跳转(jsp:forward)
    那么,你在触发execute()方法的时候直接以pop-up window的形式,是不是应该弹出一个页面.
    也就是你的return url.
    这个url你直接以*.jsp或者*.html便可.
    在*.jsp/*.html里面实现跳转.
    就能达到你想要的效果
      

  5.   


    我打算跳到一个jsp,url作为参数传过去
    <action name="Bg1_5" class="cms.Bg1_5">
    <result name="1_5" >/test.jsp?url=${url}</result>
    </action>然后jsp里面用
    <meta http-equiv="refresh" content="0;URL=<%=url%>/>请问这里的url应该如何转码,在jsp接收到后是否还需要解码啊???
      

  6.   

    这就是技巧性的东西了。 
    我相信你用过html的自动跳转(meta标签)或者是jsp自动跳转(jsp:forward) 
    那么,你在触发execute()方法的时候直接以pop-up window的形式,是不是应该弹出一个页面. 
    也就是你的return url. 
    这个url你直接以*.jsp或者*.html便可. 
    在*.jsp/*.html里面实现跳转. 
    就能达到你想要的效果
      

  7.   

    不是form
    是struts-config.xml
      

  8.   

    我把struts-config.xml改了下
    <action name="Bg1_5" class="cms.Bg1_5">
    <result name="1_5">/test.jsp/url=${url}
    </result>
      </action>
    跳转后报这样的错
    java.io.FileNotFoundException: Template /test.jsp/url=http://156.6.110.221:3488/web/servlet/thunisoft/fy/office/xtgl/yhgl/CheckLogin?sUserID=admin&sPassword=b08cd5e28176700c52e912982b3215ce&sTimestamp=1266824916&product=1 not found.
    是不是因为url没有转码的问题?
    应该怎么改呢?
      

  9.   

    http://156.6.110.221:3488/web/servlet/thunisoft/fy/office/xtgl/yhgl/CheckLogin?sUserID=admin&sPassword=b08cd5e28176700c52e912982b3215ce&sTimestamp=1266824916&product=1 直接执行下URL看哪有问题再说。
      

  10.   

    /test.jsp/url=http://156.6.110.221:3488/web/servlet/thunisoft/fy/office/xtgl/yhgl/CheckLogin?sUserID=admin&sPassword=b08cd5e28176700c52e912982b3215ce&sTimestamp=1266824916&product=1后台真正的执行URL是这样的
    http://156.6.110.221:3488/web/.../test.jsp/url=http://156.6.110.221:3488/web/servlet/thunisoft/fy/office/xtgl/yhgl/CheckLogin?sUserID=admin&sPassword=b08cd5e28176700c52e912982b3215ce&sTimestamp=1266824916&product=1你看下这是合法的URL??
      

  11.   

    原来不需要这么麻烦
    struts文件直接写<action name="Bg1_5" class="cms.Bg1_5">
    <result name="1_5">/test.html
    </result>
    </action>
    然后再test.html中<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <meta http-equiv="refresh" content="5;URL=${url}"/>
    </head>
    <body>
    ${url}
    </body>
    </html>
    就能得到这个url了但是现在的问题是:跳转到了外部系统,但是提示密码错误,然后再重新登陆一次就可以登上了。真够麻烦的啊。。
      

  12.   

    test.html  你跳转时中间经过这个页面了 你传过来的值 肯定不在了。。 呵呵
      

  13.   

    那里写错了 , 应该是一个jsp
      

  14.   

    那就用jsp咯
    jsp很强大滴..
    你改成test.jsp
    然后在跳转前将相应的用户名和密码放在session中.放在session中的变量在redirect以后是可以得到的
    那么你在test.jsp里先得到用户名和密码再跳转。
    这不就OK了吗?
      

  15.   

    如果你要带动态参数,肯定要使用jsp
    使用jsp跳转就不要用meta标签了。不好使
    还是用jsp自带的跳转功能吧
      

  16.   

    傻透了  在Button那里加个 target="_blank"就可以了  都搞定了