基于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 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!