我在java类写了一个登陆方法:
//用户名和密码登陆  
public boolean loginDemo(String name,String password){

Login login = new Login();//id,name,password 3个参数
boolean resultLogin=false;
 String sql = "select * from test_users where name='" + name
  + "' and password='" + password + "'";
 try {
stm=getconn().createStatement();
rs=stm.executeQuery(sql);
while(rs.next()){
login.setName(rs.getString(1));
login.setPassword(rs.getString(2));
resultLogin = true;

}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
       return resultLogin;

}在flex端怎么调用
   <s:Label x="86" y="147" text="用户名:" width="84" height="32"/>
<s:Label x="86" y="207" text="密码:" width="53" height="22"/>
<s:TextInput x="178" y="147"/>
<s:TextInput x="178" y="207"/>
<s:Button x="157" y="313" label="登陆"/>

解决方案 »

  1.   

    <?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">

    <fx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;

       public function sumbit():void{
       
       firstRo.loginUser(txtName.text,txtPassword.text);
       firstRo.addEventListener(ResultEvent.RESULT,loginResult);
       }
       
       private function loginResult(evt:ResultEvent):void{
      var successful:Boolean = evt.result as Boolean;
      if(successful){
    Alert.show("登录成功");
    }
      else{
      Alert.show("登陆失败");
      }
    }
     
    ]]>
    </fx:Script>

    <fx:Declarations>
    <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    <mx:RemoteObject id="firstRo" destination="returnList"/> </fx:Declarations>
    <s:Label id="labName" text="用户名" x="245" y="139"/>
    <s:TextInput id="txtName" x="317" y="139"/>
    <s:Label id="labPassword" text="密码" x="245" y="182"/>
    <s:TextInput id="txtPassword" x="317" y="182"/>
    <s:Button label="登陆" x="348" y="241" click="sumbit()"/></s:Application>