#SimpleMVC SimpleMVC---抄抄抄的产物基于Filter,结合JFinal与SpringMVC的注解式配置 参考了JFinal以及红薯的URL映射 模板引擎使用Beetl,可扩展,计划之后加入更多支持->定义一个Controller@Base(name = "/")public class TestController extends Controller { @Mapping(name = "index", method = HttpMethod.GET) public void action1() { render("/test.html"); } @Mapping(name = "method2", method = HttpMethod.POST) public void action2() { Map jsonObject = new HashMap(); renderJson(jsonObject); } @Mapping(name = "method3", method = HttpMethod.GET) public void action3() { redirect("/"); }} 启动时会自动扫描Controller完成映射 ->如何定义一个拦截器继承Interceptor类 public class TestInterceptor extends Interceptor { @Override public boolean invoke() { Controller controller = getController(); return false; }} ->使用拦截器在方法前加注释,可配置多个拦截器 @Before(name = TestInterceptor.class) @Mapping(name = "index", method = HttpMethod.GET) public void action1() { render("/test.html"); } ->额外的配置默认配置模板文件在WEB-INF/views中,可通过web.xml指定 可继承SimpleConfig类配置beetl函数等 <xmp> <filter> <filter-name>simpleMVC</filter-name> <filter-class>xyz.whiteblue.core.CoreFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>simpleMVC</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </xmp>目前仍未完成,填坑中,使用需谨慎 By WhiteBlue |
请发表评论