V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
azev
V2EX  ›  问与答

https 请求到 spring 程序,然后被重定向到了 http,可能是什么原因?

  •  
  •   azev · 348 天前 · 473 次点击
    这是一个创建于 348 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一个很老的程序,重定向是程序中判断到未登录时要求去登录页,结果发现变成了 http ,很奇怪。

    3 条回复    2023-05-25 15:47:48 +08:00
    yidinghe
        1
    yidinghe  
       348 天前 via Android
    下面是我用的办法给你参考下
    ```java
    /**
    * 创建一个重定向的 View ,并且防止从 HTTPS 跳转成为 HTTP
    */
    protected ModelAndView safeRedirect(String url) {
    return new ModelAndView(new RedirectView(url, true, false));
    }
    ```
    iyiluo
        3
    iyiluo  
       348 天前
    看前端 302 重定向的 location 跳转链接是不是 htttp 开头,如果应用用 nginx 代理了,可以在 nginx 配置把 http 跳转改成 https 跳转
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   977 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.