javasimplemvcsupportrestfulandannotation,somekindofparamswillbepostinmethod.
具体例子请查看DEMO。非常简单的MVC。springmvc精简版。
/** *demo不带参数 *
Title:
*
URL:https://127.0.0.1:8080/demo/demo/demo.html
*@throwsException */ @Route(value="/demo.html") @MethodType(type=mType.get) publicvoiddemo()throwsException{ HttpServletResponseresponse=MvcPageContextUtil.getResponse(); MvcPageUtil.resultJsonToString(response,"1111"); } /** *demo2第二种方式 *
Title:
*
URL:https://127.0.0.1:8080/demo/demo/demo3/demo2.html
*@paramdemo2 *@throwsException */ @Route(value="/{demo2}/demo2.html") @MethodType(type=mType.get) publicvoiddemo2(@RouteParam("demo2")Stringdemo2)throwsException{ HttpServletResponseresponse=MvcPageContextUtil.getResponse(); MvcPageUtil.resultJsonToString(response,demo2); } /** *参数第种方式 *
Title:
*
URL:https://127.0.0.1:8080/demo/demo/demo1.html?demo=3
*@paramdemo *@throwsException */ @Route(value="/demo1.html") @MethodType(type=mType.get) publicvoiddemo1(@QueryParam("demo")Stringdemo)throwsException{ HttpServletResponseresponse=MvcPageContextUtil.getResponse(); MvcPageUtil.resultJsonToString(response,demo); } /** *第三种方式 *
Title:
*
URL:https://127.0.0.1:8080/demo/demo/demo3.html?demo=3
*@paramdemo *@throwsException */ @Route(value="/demo3.html") @MethodType(type=mType.get) publicvoiddemo3(@FormParam("demo")Stringdemo)throwsException{ HttpServletResponseresponse=MvcPageContextUtil.getResponse(); MvcPageUtil.resultJsonToString(response,demo+"_第三种方式"); } /** * *
Title:
*
URL:https://127.0.0.1:8080/demo/demo/demo4/sa/demo6.html> *@paramdemo4 *@throwsException */ @Route(value="/demo4/sa/{demo4}.html",cls=demoInterceptot.class) @MethodType(type=mType.get) publicvoiddemo4(@RouteParam("demo4")Stringdemo4)throwsException{ HttpServletResponseresponse=MvcPageContextUtil.getResponse(); MvcPageUtil.resultJsonToString(response,demo4); }
/***参数第种方式*<p>Title:</p>*<p>URL:https://127.0.0.1:8080/demo/demo/demo7.html?demo=3&demo1=4</p>*@paramdemo*@throwsException*/@Route(value="/demo7.html")@MethodType(type=mType.get)publicvoiddemo7(@QueryParam("demo")JSONObjectdemo)throwsException{HttpServletResponseresponse=MvcPageContextUtil.getResponse();MvcPageUtil.resultJsonToString(response,demo.toJSONString());}
评论