14

Restletリクエストオブジェクトからパラメータを取得する方法を理解しようとしています。

私のリクエストは/customer?userId = 1として届き、クエリのためにDAOに渡すパラメータを取得したいと思います。

public class CustomerResource extends ServerResource
{
  @Get("xml")
  public Representation toXml() throws ResourceException, Exception
  {
      try
      {
          //get param from request
         //call DAO with parameter
      }
      catch(Exception e)
      {
          throw e;
      }
  }
}
4

2 に答える 2

30

私はそれを考え出した....

public class CustomerResource extends ServerResource
{
  @Get("xml")
  public Representation toXml() throws ResourceException, Exception
  {
      try
      {
          //get param from request
          getQuery().getValues("userId")
         //call DAO with parameter
      }
      catch(Exception e)
      {
          throw e;
      }
  }
}
于 2010-05-05T16:08:54.497 に答える
7

そのためのショートカット方法があることに注意してください:

String paramValue = getQueryValue("userId");

お役に立てば幸いです。

于 2013-04-15T07:55:25.157 に答える