简体   繁体   中英

How to get the domain name of client accessing spring boot application?

I want to get the domain names who are accessing my application. I tried with :getHostName(),getServerName()... All gives the the domain of the Server, not the cient, I want to get domain name of client..

You can inject HttpServletRequest in your controller's method and use

@GetMapping("/getInfo")
public void getRemoteHost(HttpServletRequest request,...) {
     System.out.println("=========> "+request.getRemoteAddr());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM