简单的MVC框架 jdmvc
本文导语: java simple mvc support restful and annotation ,some kind of params will be post in method. 具体例子请查看DEMO。非常简单的MVC。spring mvc精简版。 /** * demo 不带参数 * Title: * URL:http://127.0.0.1:8080/demo/demo/demo.html * @thr...
java simple mvc support restful and annotation ,some kind of params will be post in method.
具体例子请查看DEMO。非常简单的MVC。spring mvc精简版。
/**
* demo 不带参数
*
Title:
*
URL:http://127.0.0.1:8080/demo/demo/demo.html
* @throws Exception
*/
@Route(value="/demo.html")
@MethodType(type=mType.get)
public void demo() throws Exception{
HttpServletResponse response=MvcPageContextUtil.getResponse();
MvcPageUtil.resultJsonToString(response, "1111");
}
/**
* demo2 第二种方式
*
Title:
*
URL:http://127.0.0.1:8080/demo/demo/demo3/demo2.html
* @param demo2
* @throws Exception
*/
@Route(value="/{demo2}/demo2.html")
@MethodType(type=mType.get)
public void demo2(@RouteParam("demo2") String demo2) throws Exception{
HttpServletResponse response=MvcPageContextUtil.getResponse();
MvcPageUtil.resultJsonToString(response, demo2);
}
/**
* 参数第种方式
*
Title:
*
URL:http://127.0.0.1:8080/demo/demo/demo1.html?demo=3
* @param demo
* @throws Exception
*/
@Route(value="/demo1.html")
@MethodType(type=mType.get)
public void demo1(@QueryParam("demo") String demo) throws Exception{
HttpServletResponse response=MvcPageContextUtil.getResponse();
MvcPageUtil.resultJsonToString(response, demo);
}
/**
* 第三种方式
*
Title:
*
URL:http://127.0.0.1:8080/demo/demo/demo3.html?demo=3
* @param demo
* @throws Exception
*/
@Route(value="/demo3.html")
@MethodType(type=mType.get)
public void demo3(@FormParam("demo") String demo) throws Exception{
HttpServletResponse response=MvcPageContextUtil.getResponse();
MvcPageUtil.resultJsonToString(response, demo+"_第三种方式");
}
/**
*
*
Title:
*
URL: http://127.0.0.1:8080/demo/demo/demo4/sa/demo6.html>
* @param demo4
* @throws Exception
*/
@Route(value="/demo4/sa/{demo4}.html",cls=demoInterceptot.class)
@MethodType(type=mType.get)
public void demo4(@RouteParam("demo4") String demo4) throws Exception{
HttpServletResponse response=MvcPageContextUtil.getResponse();
MvcPageUtil.resultJsonToString(response, demo4);
}
Title:
URL:http://127.0.0.1:8080/demo/demo/demo7.html?demo=3&demo1=4