我想使用HTTP服務連接flex和java。從flex發送到java的參數
<?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" minWidth="955" minHeight="600"
bcreationComplete="initApp();">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function initApp():void {
b1.addEventListener(MouseEvent.CLICK, myEventHandler);
}
private function myEventHandler(event:Event):void {
Alert.show("An event occurred."+t1.text);
srv.send("abc");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="srv" url="http://localhost:8080/JavaFlex/rest/flextest">
</s:HTTPService>
</fx:Declarations>
<s:Label>
Ur message
</s:Label>
<s:TextInput id="t1"/>
<s:Button id="b1" label="Submit" x="120" y="50">
</s:Button>
<mx:DataGrid x="220" y="150" dataProvider="{srv.lastResult}"/>
</s:Application>
我打電話給休息服務。 (find all)方法被調用,但是「msg」參數沒有被傳遞。這是我的休息服務。在控制檯中顯示
@Path("/flextest")
public class chartServer {
@GET
@Produces({"text/plain"})
public String findAll(String msg) throws SQLException {
ArrayList<Integer> temp=new ArrayList<Integer>();
System.out.println("op is "+ msg);
System.out.println("Rest Api invoked");
chartData r= new chartData();
temp= (ArrayList<Integer>) r.data();
System.out.println("From rest "+temp);
return msg;
}
}
輸出是 op is
爲什麼不顯示參數?
謝謝。如何訪問java中的值 – Niketa