flex 与jsp 通信问题
为什么我装的flex没有办法与jsp通信啊,在网上找了好几个flex和jsp通信的例子,如最简单的登入都没有办法实现,难道与还需要配置flex,我用的例子是
mxml代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private function loginHandle():void {
doLogin.send();
}
private function loginResult(evt:ResultEvent):void {
if(evt.result.loginResult=="yes")
{
Alert.show("登入成功");
} else {
Alert.show("用户名或密码错误!");
}
}
private function loginSuccess():void {
var successful:String = "./SUC.jsp";
var request:URLRequest = new URLRequest(successful);
navigateToURL(request,"_self");
}
]]>
</mx:Script>
<mx:HTTPService id="doLogin" result="loginResult(event)"
showBusyCursor="true" method="POST" url="./index.jsp" >
<mx:request>
<username>
{nametxt.text}
</username>
<password>
{passwordtxt.text}
</password>
</mx:request>
</mx:HTTPService>
<mx:Panel x="10" y="53" width="412" height="256" layout="absolute">
<mx:Label x="31" y="49" text="用户名" width="72"/>
<mx:Label x="31" y="96" text="密 码" width="43"/>
<mx:TextInput x="82" y="47" id="nametxt"/>
<mx:TextInput x="82" y="94" id="passwordtxt" displayAsPassword="true"/>
<mx:Button x="58" y="167" label="ok" click="loginHandle()" />
<mx:Button x="151" y="167" label="cancel"/>
</mx:Panel>
</mx:Application>
jsp代码:
<%
String uname = request.getParameter("username");
String password = request.getParameter("password");
System.out.println(uname);
System.out.println(password);
out.println("<loginResult>yes</loginResult>");
%>
------解决方案--------------------
这个可以参考一下。
http://blog.chinaunix.net/u/21684/showart_1008091.html