Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用HTTPservice将数据从MXML文件发送到JSP文件(并接收)_Xml_Apache Flex_Jsp_Actionscript_Adobe - Fatal编程技术网

使用HTTPservice将数据从MXML文件发送到JSP文件(并接收)

使用HTTPservice将数据从MXML文件发送到JSP文件(并接收),xml,apache-flex,jsp,actionscript,adobe,Xml,Apache Flex,Jsp,Actionscript,Adobe,我想从数据库中检索数据,并在Flex web应用程序的datagrid中显示。我的想法是: 使用HTTPService将.mxml文件中的查询数据发送到.jsp页面 在.jsp中,连接到数据库并使用select语句检索数据 使用HTTPService将结果发送回.mxml 我知道该用什么,但我有点模棱两可。在(.mxml)中,我使用xxx.send()发送数据。我在(.jsp)中使用什么将其发送回 另外,我知道我应该将结果存储在.jsp文件中的XML中,但是如何做到这一点呢?您只需将XML数据直

我想从数据库中检索数据,并在Flex web应用程序的datagrid中显示。我的想法是:

  • 使用HTTPService将.mxml文件中的查询数据发送到.jsp页面
  • 在.jsp中,连接到数据库并使用select语句检索数据
  • 使用HTTPService将结果发送回.mxml
  • 我知道该用什么,但我有点模棱两可。在(.mxml)中,我使用xxx.send()发送数据。我在(.jsp)中使用什么将其发送回


    另外,我知道我应该将结果存储在.jsp文件中的XML中,但是如何做到这一点呢?

    您只需将XML数据直接输出到屏幕上,就像处理任何其他jsp网页一样。假设您正在制作一个jsp来显示一些html,同样的概念也适用,只需显示XML即可

    • yourpage.jsp:

      <% java.util.Date date = new java.util.Date(); %>
      <root><time><%= date %></time></root>
      

      我不太懂Java语法。通常,服务器端代码将位于服务器端文件中具有指定返回类型的方法/函数中。您将使用“return myValue”返回数据。如果您只是生成一个页面,而不是调用一个服务,那么您的结果将是屏幕输出;它将作为字符串返回。
      <mx:HTTPService id="myService" url="yourpage.jsp" method="GET" 
          resultFormat="e4x" result="myServiceResponse(event)" fault="httpFaultHandler(event)" showBusyCursor="true"/>
      
      private function settingsResponse( e : ResultEvent) : void {
          myXML = e.result as XML;
          mx.controls.Alert.show('current server date/time is ' + String(myXML.time) );
          //   ...do whatever you want with your xml now!...
      }