I'm trying to get a list of all online users. I'm planning to do so, using SpringRegistry. But i also have to get user's browser info and ip address. I know that i could do it in javascript, but i need to retrieve all user's details, not only current one's.
EDIT
Here's my code:
@GetMapping("/")
public String index(HttpServletRequest request){
String ip=request.getRemoteAddr(); // "0:0:0:0:0:0:0:1"
return "index";
}
Just add HttpServletRequest object in your method and get the ip using getRemoteAddr() method.No Spring required.Something like this :
public void doSomething(HttpServletRequest request){
System.out.print(request.getRemoteAddr()); // Prints ip address
}
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.