Flex obtains ip and pcname sample code through java background
The code in ***DAOImpl.java is as follows
public String getCompuName() { Map<String, String> map = System.getenv() ; String computerName = map.get("COMPUTERNAME");// 获取计算机名 return computerName; } public String getIp() { InetAddress addr = null; try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); } String ip = addr.getHostAddress().toString();//获得本机IP return ip; }
Copy after login
Need to introduce
import java.util.Map; import java.net.InetAddress; import java.net.UnknownHostException;
Copy after login
flex front-end code
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" minWidth="955" minHeight="600" creationComplete="init()"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; public function init():void { IPandPcname.getCompuName(); IPandPcname.getIp(); } public function IPandPcname_faultHandler(event:FaultEvent):void { Alert.show(event.toString()); } public function getCompuName_Handler(event:ResultEvent):void { Alert.show(event.result.toString()); } public function getIp_Handler(event:ResultEvent):void { Alert.show(event.result.toString()); } ]]> </fx:Script> <s:layout> <supportClasses:AttachmentLayout/> </s:layout> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <mx:RemoteObject id="IPandPcname" destination="systemConfAction" fault="IPandPcname_faultHandler(event)"> <mx:method name="getCompuName" result="getCompuName_Handler(event)" /> <mx:method name="getIp" result="getIp_Handler(event)" /> </mx:RemoteObject> </fx:Declarations> </s:Application>
Copy after login
More flex obtains ip and pcname through the java background For articles related to sample code, please pay attention to the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Roblox: Dead Rails - How To Complete Every Challenge
4 weeks ago
By DDD
Atomfall guide: item locations, quest guides, and tips
4 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1393
52


C# Tutorial
1206
24

