简体   繁体   English

如何处理Restlet资源中的过滤

[英]How to handle filtering in restlet resource

Hi i am pretty new to Restlet, and generally building web servers. 嗨,我是Restlet的新手,并且通常在构建Web服务器。 I need to support filtering like this: http://deviceip:port/resource?id=id 我需要支持这样的过滤: http:// deviceip:port / resource?id = id

So far i know how to return a json message when user invokes different resources, based on my web server state. 到目前为止,我知道基于用户的Web服务器状态,当用户调用其他资源时如何返回json消息。 I would attach it to router, and add class which handles that resource. 我将其附加到路由器,并添加处理该资源的类。 But how can i return only one resource from collection based on id? 但是,如何才能基于ID从集合中仅返回一种资源? What i need to change in my class which is responsible from handling of that resource. 我需要在班上更改需要处理该资源的内容。 Also how can i attach this resource to router? 另外,我如何将此资源附加到路由器? Any help is welcome, if you can write some code snippet to help me, that would be great. 欢迎您提供任何帮助,如果您可以编写一些代码段来帮助我,那将非常好。

Thanks 谢谢

So as i understand you can approach to this in two ways. 因此,据我了解,您可以通过两种方式解决此问题。 One is explained by link above and another one is using query. 一个通过上面的链接解释,另一个在使用查询。 So basically you font have to create another resource like in the answer from link above, instead you can just extract query with this.getQuery() and than call method getFirstValue("id") , which will return entered id. 因此,基本上,字体必须像上面链接中的答案一样创建另一个资源,相反,您可以仅使用this.getQuery()提取查询,然后调用方法getFirstValue("id") ,该方法将返回输入的id。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM