Java 从Restlet请求获取HTTP Get参数

Java 从Restlet请求获取HTTP Get参数,java,rest,restlet,Java,Rest,Restlet,我试图弄清楚如何从Restlet请求对象获取参数 我的请求以/customer?userId=1的形式出现,我想获取参数以传递给我的DAO进行查询 public class CustomerResource extends ServerResource { @Get("xml") public Representation toXml() throws ResourceException, Exception { try { //get p

我试图弄清楚如何从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;
      }
  }
}
我想出来了

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;
      }
  }
}

请不要告诉我有一个快捷方式:

String paramValue = getQueryValue("userId");

希望它能帮助你。

我也很难弄清楚。现在是2014年,我仍然觉得很难弄清楚:)谢谢你的解决方案!