grails - 如何在Grails中找出已连接的客户端IP地址

标签 grails groovy

我正在做小项目。我正在尝试在此项目中添加网络概念,请您指导如何进行工作

要求:-

I am running my project in my localhost(http://localhost:8080/xyz).So if another person is accessing the project with the same localhost(http://192.168.x.x:8080/xyz).By using the networking concept i should get the details of that particular users ip address who using with the same localhost (IP address).



目前,我正在使用此查询来获取系统的IP地址
${request.getScheme()}:${InetAddress.getLocalHost().getHostAddress()}

但我想要在网络中使用此项目的特定用户的IP地址。

请指导我解决这个问题。

最佳答案

您应该可以使用:

String addr = request.remoteAddr

关于grails - 如何在Grails中找出已连接的客户端IP地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7763338/

相关文章:

java - 如何使用 groovy 将另一个 xml 文件内容添加到现有 xml 创建中

json - 如何使用httpbuilder在groovy中将http get响应作为完整的json字符串检索

java - 具有类路径问题的 grails war 的 Tomcat 部署

grails - Grails 2升级问题

database - 在 grails 中为一个应用程序使用两个数据库

java - 内存不足异常 : When reading 11GB XML using simple groovy getting memory error but when reading using plain JAVA not error

groovy - 项目 (':projectName' ) {} 和 $projectRoot/projectName/build.gradle 之间有什么区别

mongodb - 无法下载Grails Datastore Gorm 3.1.3版本

从服务到 Controller 的 Grails 依赖注入(inject)不起作用

grails - 如何使用Geb访问外部网站