【发布时间】:2012-12-12 20:11:20
【问题描述】:
Dojo 网格通过向 REST Web 服务发出请求来实现排序,如下所示:
GET http://server/request?sort(+id)
sort(+id) 是方向 (+/-) 和要排序的列。
目前我正在这样做,它可以工作,但它很难看:
@GET
@Path("request/")
@Produces(MediaType.APPLICATION_JSON)
public Collection<RequestDataWithCurrentStatus> getAllRequests() {
Collection<RequestDataWithCurrentStatus> col = new ArrayList<RequestDataWithCurrentStatus>();
....
//handle the various types of sorting that can be requested by the dojo widget
String queryString = this.request.getQueryString();
//parse the dojo sort string 'sort(+id)' and sort
...
return col;
}
此方法使用 RESTEasy 注入 @Context private HttpServletRequest request 来访问原始查询字符串。
我觉得我应该能够在我的getAllRequests() 调用中将此查询字符串映射到RESTEasy 的@*Param 注释之一。但是根据 RESTEasy 的documentation,似乎没有一个很好的映射到文档中的螺旋 dojo 查询字符串。我想做这样的事情:
@GET
@Path("request/")
@Produces(MediaType.APPLICATION_JSON)
public Collection<RequestDataWithCurrentStatus> getAllRequests( @DojoQueryParam String sort) {
...
}
如何以正确的方式将 dojo 网格查询字符串编组为 RESTEasy Web 服务方法?
【问题讨论】:
标签: java dojo jax-rs resteasy dojox.grid.datagrid