2017-08-07 19:37
@九块腹肌进先生 建议使用 jfinal ActiveRecordPlugin 自带的 sql 管理功能,在 jfinal 手册中有详细的使用说明
2017-08-07 19:23
换一个思路解决,在 configInterceptor(Interceptors me) 方法中添加一个业务层全局拦截器:
me.addGlobalServiceInterceptor(new MyInterceptor());
然后让这个 MyInterceptor 去决定哪些目标有拦截动作,哪些该直接放行,大致逻辑如下:
public void intercept(Invocation inv) {
Object target = inv.getTarget();
if (needInterceptTarget(target)) {
doInterept(target);
}
inv.invoke();
}
2017-08-07 19:17
@Jason、 参考 FakeStaticHandler 稍微改点代码即可解决,大致方向是将 String target 这个值变成最终可以抵达 action 的正确值
例如 target = "detail/25.html" 这种风格,用类似下面的代码搞定:
int index = target.lastIndexof(".");
if (index != -1) {
target = target.substring(0, index);
}
next.handle(target, request, response, isHandled);
然后在 controller 中可以这样:
Integer id = getParaToInt();
setAttr("item", xxService.detail(id));
render(...);
看 FakeStaticHandler 关键在于举一反三,而不在于直接使用