使用HttpServletRequest获取请求发送者的URL [英] Get URL of the request sender with HttpServletRequest

查看:124
本文介绍了使用HttpServletRequest获取请求发送者的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用HttpServletRequest获取源域?源域是请求者的域.

How do you get the source domain using HttpServletRequest? Source domain is the requester's domain.

谢谢.

推荐答案

您可以选择

// gets client (browser)'s hostname
String host = request.getRemoteHost(); 

OR

// get the server's domain name.
String domain = new URL(request.getRequestURL().toString()).getHost(); 

这篇关于使用HttpServletRequest获取请求发送者的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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