request.getScheme()返回http而不是在java中返回https [英] request.getScheme() is returning http instead of returning https in java

查看:519
本文介绍了request.getScheme()返回http而不是在java中返回https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function demo(request,response){
        request.getScheme() is returning http instead of returning https.
        System.out.println(""+request.getScheme());
}

输出:http

- 上面的函数demo是从main方法调用的,但它打印http而不是它应该在Internet服务器上打印时打印https。

--above function demo is being called from main method but it prints http instead it should print https while working on internet server.

推荐答案

请参阅 https://stackoverflow.com/a/19599143/1524502 的答案,并注意有关存在的问题反向代理或负载均衡器后面。最有可能的是,这是你的问题。

See the answer https://stackoverflow.com/a/19599143/1524502, and note the issues about being behind a reverse proxy or load balancer. Most likely, that is your problem.

该问题的回答者建议使用

The answerer in that question recommended using

request.getHeader("x-forwarded-proto")

相反,尽管如此取决于您的负载均衡器正确设置标题。

instead, though that is dependent on your load balancer setting the header correctly.

这篇关于request.getScheme()返回http而不是在java中返回https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆