Ajax和Wicket:找到RESTful Web服务的URL

时间:2014-10-13 14:21:53

标签: jquery ajax web-services wicket wicketstuff

我需要在wicket应用程序中创建一个登录web服务,并从jQuery $ .ajax()函数调用它。我找到了wicketstuff-restannotations并尝试了这段代码:

public static class DestinationUrl implements Serializable
{
  private String authorizedUrl;

  public String getAuthorizedUrl()
  {
    return authorizedUrl;
  }

  public void setAuthorizedUrl(String authorizedUrl)
  {
    this.authorizedUrl = authorizedUrl;
  }

}

public static class GsonLogonService extends GsonRestResource implements Serializable
{
  private AuthenticatedWebSession session;

  public AuthenticatedWebSession getSession()
  {
    return session;
  }

  public void setSession(AuthenticatedWebSession session)
  {
    this.session = session;
  }

  @MethodMapping(value = "/loginService", httpMethod = HttpMethod.POST)
  public DestinationUrl logonService(@RequestBody String username, @RequestBody String password)
  {
    DestinationUrl result = new DestinationUrl();
    if (session.signIn(username, password))
      result.setAuthorizedUrl(RequestCycle.get().getRequest().getOriginalUrl().toString());
    else
      result.setAuthorizedUrl("/");
    return result;
  }

}

但是为了使该服务出现在/ logonService或/ MyContext / logonService下,我还应该做些什么呢?使用$ .ajax()或$ .get()调用其中任何一个yelds 404 ...

0 个答案:

没有答案