用Grails REST重写Java控制器类

问题描述:

我在Spring上使用Java实现了一个REST应用程序。 GET和DELETE请求的示例如下:用Grails REST重写Java控制器类

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

我正在寻找Grails并希望用Grails重写我的控制器。我阅读了一些文章,它表明,不需要在Grails中编写这些注释。我只会定义我的clousers,它会像我的Spring应用程序一样呈现对JSON对象的响应。我怎样才能用闭包来实现它们? (我使用IntelliJ IDEA 10.3)

此代码中没有任何内容可以使用闭包。

在grails中它可能看起来一样,或者你可以把url映射放在UrlMappings.groovy