Struts2+Flex开发

来源:互联网 发布:ubuntu fcitx输入法 编辑:程序博客网 时间:2024/06/11 01:47

首先你可以用XML来实现,这个应该来说比较普遍。不用XML的话,也可以返回数据给FLEX。但是不用action的跳转public String execute()throws Exception {  if(action.checkUser(getName(), getPassword()))  {   response.getWriter().write("success");  }else   {     response.getWriter().write("error");  }  return null; }比如在action里,判断用户登录成功返回success给FLEX,失败返回error.记住最后要返回null,因为不用action的跳转。Flex里用HTTPService来发出请求,如下:<mx:HTTPService id="service" url="http://localhost:8080/JavaEEFlex/login" result="serviceRequest(event)"  method="POST" >             <mx:request xmlns="">              <name>                  {na.text}              </name>            <password>             {password.text}            </password>          </mx:request>    </mx:HTTPService>  然后用FLEX接受数据:private function serviceRequest(event:ResultEvent):void{       if(event.result.toString()=="success")        {          ExternalInterface.call("function(){window.location.href='http://localhost:8080/JavaEEFlex/Content.html';}");     }           if(event.result.toString()== "error")        {            Alert.show('用户名或密码有误');        }     }   基本就是如上了。