类似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("

1<html><head><title>");   
2out.println("This is my first Servlet");   
3out.println("</title></head><body>");   
4out.println("<h1>Hello,World!</h1>");   
5out.println("</body></html>

");

}
}

2。mxml

1<mx:application verticalgap="10" xmlns:mx="http://www.macromedia.com/2003/mxml">
2<mx:httpservice contenttype="application/xml" id="ws" method="POST" resultformat="text" url="http://localhost:8080/servlet/helloworld">
3</mx:httpservice>
4<mx:button click="ws.send();" label="Getvalue"></mx:button>
5<mx:textinput height="300" id="myResult" text="{ws.result}" width="500"></mx:textinput>
6</mx:application>

得到结果:

本主题包含附件: sf_200411494613.jpg (11311bytes)

Published At
Categories with Web编程
Tagged with
comments powered by Disqus