博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flex取得客户端的IP地址
阅读量:2426 次
发布时间:2019-05-10

本文共 1216 字,大约阅读时间需要 4 分钟。

以下是mxml 和jsp文件:

<?
xml version
=
"
1.0
"
 encoding
=
"
utf-8
"
?>
<
mx:Application xmlns:mx
=
"
http://www.adobe.com/2006/mxml
"
 layout
=
"
vertical
"
>
<
mx:Script
><!
[CDATA[
  import mx.rpc.events.ResultEvent;
  
  [Bindable]
  private 
var
 _sClientIPUrl:String 
=
 
"
http://localhost:8600/myip.jsp
"
;
  
  
/** Runs on creationComplete */
  private 
function
 initApp():
void
 
 
{
    dsClientIP.send();                    
//invokes the data service call
 }
 
 
/** called by the result event of the data service call */
 private 
function
 onResult(oEvent:ResultEvent):
void
 
{
   
var xmlResult:XML = XML(oEvent.result);    //get the result as XML
   //trace(xmlResult);
   var sIp:String = xmlResult.@clientIP;      //get the attribute value
   //trace(sIp);
   lbIP.text = sIp;                           //display it 
 }
]]
></
mx:Script
>
 
  
<
mx:Label id
=
"
lbIP
"
 fontSize
=
"
26
"
 
/>
  
<
mx:Button x
=
"
20
"
 y
=
"
20
"
 label
=
"
send
"
 click
=
"
initApp();
"
/>
  
<
mx:HTTPService id
=
"
dsClientIP
"
 
     url
=
"
{_sClientIPUrl}
"
 
     result
=
"
onResult(event)
"
 
     resultFormat
=
"
e4x
"
/>
</
mx:Application
>

 

myip.jsp:

<%
@ page contentType="text/xml; charset=UTF-8" 
%>
<?
xml version="1.0" encoding="utf-8"
?>
<
systemdata 
clientIP
='<%=request.getRemoteHost()%
>
[
<%
=
request.getRemoteAddr()
%>
]'/>
 

转载地址:http://nbfmb.baihongyu.com/

你可能感兴趣的文章
黎曼猜想漫谈
查看>>
CRM基础教程
查看>>
内存数据管理(第2版)
查看>>
深入理解Android:卷II
查看>>
QTP自动化测试最佳实践
查看>>
捉虫日记
查看>>
jQuery Mobile权威指南
查看>>
决战第三屏:移动互联网时代的商业与营销新规则
查看>>
方刚先生谈《胜于言传——网站内容制胜宝典》
查看>>
php以图搜图
查看>>
三种保证URL地址可信的加密方式
查看>>
memcached 并发原语CAS与GETS操作
查看>>
memcached(六)调优经验
查看>>
赶集mysql军规
查看>>
mysql使用索引优化order排序
查看>>
mysql复合索引、普通索引总结
查看>>
mysql explain中的using filesort
查看>>
MYSQL explain详解
查看>>
MySQL查询优化-explain
查看>>
Java 反射和动态代理真的没那么高深,一起来看看就知道了
查看>>