开发者

Rewriting Java Controller Class with Grails REST

I have implemented a REST application with Spring at Java. An example of GET and DELETE requests 开发者_运维问答are as follows:

@RequestMapping(method = RequestMethod.GET)
public
@ResponseBody
List<Configuration> getAllConfigurationsInJSON() {
    return new ArrayList<Configuration>(configurationMap.values());
}

@RequestMapping(value = "{systemId}", method = RequestMethod.DELETE)
public void deleteConfiguration(HttpServletResponse response, @PathVariable long systemId) throws IOException {
    if (configurationMap.containsKey(systemId)) {
        configurationMap.remove(systemId);
        response.setStatus(HttpServletResponse.SC_OK);
    } else {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}

I am searching about Grails and want to rewrite my controller with Grails. I read some articles and it shows that there is no need to write that annotations at Grails. I will just define my clousers and it will render my response to JSON object as like my Spring applicaiton. How can I implement them with closures? (I use IntelliJ IDEA 10.3)


There is nothing in this code that can make use of closures.

In grails it may look the same, or you can put the url mappings in UrlMappings.groovy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜