基于Groovy + SpringMVC 的一套Rest JSON API
CoC 理念的一套HTTP JSON API框架,基于SpringMVC 和 Groovy,内置了 MongoDB CRUD模版(JSON和MongoDB天然好基友)!!
Overview
- Write Your Controller In Groovy
@Rest class MyController extends ControllerSupport7 { def hello(HttpServletRequest req) { [code: 1, data: "Hello, ${req['name']} !"] } }
- Open http://localhost:8080/
my/hello?name=World
{"code":1,"data":"Hello, World !"} That's ALL !!!
- the main Convention
As you see,my is the Controller Name (first lowercase) and hello is the method Name.This is The main Convention.
Don't forget the @Rest annotation on the controller.
@Rest=@Controller(SpringMVC) +@CompileStatic(Groovy)
@RestWithSesson=@Controller+@CompileStatic+@Interceptors
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!