zoukankan      html  css  js  c++  java
  • 两个不同的项目间页面的跳转总结

      最近在项目中碰到一个棘手的问题,我们的项目是用两种语言写的,其两者之间会有一些跳转的交互。我所面临的问题就是通过Java项目调到ruby项目,然后还能由ruby项目跳转到Java项目。第一次做这个有点不知所措。最后用了解决方案(PS:项目中session共享问题已经解决了)。

      第一种解决办法是在前端做控制,window.location.herf进行连接的跳转。但是这个只能操作当前的window,因为我们的项目中是Java页面作为一个iframe嵌套在ruby页面中。所以要变父页面的URL或者说就是整个页面的URL。总结一下:window.location.herf

      javascript中的location.href有很多种用法,主要如下。

    1 self.location.href="/url" 当前页面打开URL页面
    2 location.href="/url" 当前页面打开URL页面
    3 windows.location.href="/url" 当前页面打开URL页面,前面三个用法相同。
    4 this.location.href="/url" 当前页面打开URL页面
    5 parent.location.href="/url" 在父页面打开新页面
    6 top.location.href="/url" 在顶层页面打开新页面

      如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开url地址

      此外,window.location.href=window.location.href;和window.location.Reload()和都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href=window.location.href;则是向指定的url提交数据.

      最重要的是window.location.href 语句可以实现一个框架的页面在执行服务器端代码后刷新另一个框架的页面

      "window.location.href"、"location.href"是本页面跳转
      "parent.location.href"是上一层页面跳转
      "top.location.href"是最外层的页面跳转

      举例说明:

      如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写

      "window.location.href"、"location.href":D页面跳转
      "parent.location.href":C页面跳转
      "top.location.href":A页面跳转

      如果D页面中有form的话,

      <form>: form提交后D页面跳转
      <form target="_blank">: form提交后弹出新页面
      <form target="_parent">: form提交后C页面跳转
      <form target="_top"> : form提交后A页面跳转
     
      关于页面刷新,D 页面中这样写:

      "parent.location.reload();": C页面刷新 (当然,也可以使用子窗口的 opener 对象来获得父窗口的对象:window.opener.document.location.reload(); )

      "top.location.reload();": A页面刷新

      第二种是在后端重定向到指定的URL,后端我们是使用springMVC,直接可以写URL来实现跳转,代码如下:

    1 @RequestMapping("redirect/{agentPartyId}/{flag}")  
    2     public String redirect(@PathVariable String agentPartyId, @PathVariable String flag){
    3         PropertyPlaceholderConfigurer bean = SpringContext.getBean(PROPERTY_CONFIG_BEAN);
    4         Properties pros = bean.getProperties();
    5         String rubyServerUrl = pros.getProperty(RUBY_SERVER_URL);
    6         String url = rubyServerUrl + "/integration/t0?ext=/apply/"+agentPartyId+flag;
    7         logger.info("apply redirect url={}", url);
    8         return "redirect:" + url;
    9     }

      大致想到的两种解决方案就是这样。

     

  • 相关阅读:
    C# Math.Round的枚举参数
    Literature Review: Incremental Segment-Based Localization in 3D Point Clouds
    Literature Review: Benchmarking 6DOF Outdoor Visual Localization in Changing Conditions
    Literature Review: Improving Image-Based Localization by Active Correspondence Search
    Literature Review: 基于稀疏直接法的建图
    论文阅读: 基于SLAM的使用GPS和鱼眼相机第Integrity Monitoring
    论文阅读: v-charge项目: 电动车的自动泊车和充电
    论文阅读: Infrastructure-Based Calibration of a Multi-Camera Rig
    论文阅读: Building a 3-D Line-Based Map Using Stereo SLAM
    论文阅读: VITAMIN-E: Extremely Dense Feature Points
  • 原文地址:https://www.cnblogs.com/lcngu/p/6107131.html
Copyright © 2011-2022 走看看