本文主要是介绍类似Xmlhttp获取数据的Flex方法~,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
通信还是用httpservice这和xmlhttp获得远端数据的方法是差不多的~
简单例子如下:
1。servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>");
out.println("This is my first Servlet");
out.println("</title></head><body>");
out.println("<h1>Hello,World!</h1>");
out.println("</body></html>");
}
}
2。mxml
<?xml version="1.0" encoding="gb2312"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" verticalGap="10">
<mx:HTTPService id="ws" url="http://localhost:8080/servlet/helloworld"
resultFormat="text"
method="POST"
contentType="application/xml">
</mx:HTTPService>
<mx:Button label="Getvalue" click="ws.send();"/>
<mx:TextInput id="myResult" text="{ws.result}" width="500" height="300"/>
</mx:Application>
得到结果:
本主题包含附件: sf_200411494613.jpg (11311bytes)
这篇关于类似Xmlhttp获取数据的Flex方法~的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!