道場網格工具通過發出請求到web服務REST像這樣排序由:道場格排序和的RESTEasy JAX-RS
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服務方法的正確方法?
太棒了!我非常專注於將RESTEasy折服到我的意願,我甚至沒有想到只是讓客戶端做正確的事情。我完全忽略了'sortParam'屬性。謝謝! – awm129