在GWT中,控制权将发生在故障()的原因是什么?

时间:2010-11-19 06:04:02

标签: gwt

public interface LoginService extends RemoteService {
         public static final String SERVICE_URI = "/login";
         public static class Util {
            public static LoginServiceAsync getInstance() {

               LoginServiceAsync instance = (LoginServiceAsync) GWT.create(LoginService.class);
               ServiceDefTarget target = (ServiceDefTarget) instance;
               target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
               return instance;
            }
         }
       public boolean userIsValid( Map loginData );
      }

和Entry类是

 public void onModuleLoad() {


      final LoginServiceAsync loginService = ( LoginServiceAsync )GWT.create( LoginService.class );
      ServiceDefTarget endpoint = ( ServiceDefTarget )loginService;
      String moduleRelativeURL = GWT.getModuleBaseURL()+"login";
      endpoint.setServiceEntryPoint( moduleRelativeURL );
      this.setLoginPanel();
      final AsyncCallback callback = new AsyncCallback()
      {

         public void onSuccess( Object result ) {

            // take the result coming from the server
            boolean ok = Boolean.valueOf( result.toString() ).booleanValue();
            if( ok )
            {

               MessageBox.alert( "Success", "Successfully logged in!");
            }
            else
            {

               MessageBox.alert( "Invalid", "Wrong username or password");
            }
         }

         public void onFailure( Throwable caught ) {
            MessageBox.alert( "Error", "Error while logging in" );
         }
      };
      loginButton = new Button( "Login" );
      loginButton.addListener( new ButtonListenerAdapter() {
         public void onClick( Button button, EventObject e ) {
            Map loginData = getUserData( formPanel.getForm() );
            loginService.userIsValid( loginData, callback );
         }
      });
      formPanel.addButton( loginButton );
      loginPanel.setBorder( false );
      loginPanel.setPaddings( 5 );
      loginPanel.add( formPanel );
      RootPanel.get().add( loginPanel );
   }


这是服务器实现类

public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
      public boolean userIsValid( Map loginData )
   {
      boolean accepted = false;
      String name = loginData.get( "userName" ).toString();
      String pswd = loginData.get( "pswd" ).toString();
      if( name.equals( "yugal" ) && pswd.equals( "yugal" ) )
      {

         accepted = true;
      }
      else
      {

            accepted = false;
      }
      return accepted;
   }
}


这是web.xml


         LoginService
         org.arosys.server.LoginServiceImpl
 

 
         LoginService
         /login
 


控制是在onFailure(Throwable caught)方法,为什么? 有什么问题?

1 个答案:

答案 0 :(得分:0)

没有任何服务实现代码,没有堆栈跟踪,这是不可能的。请给我们提供一些代码和抛出的异常吗?

Here有关如何处理异常的一些信息。