JFinal2.1中尝试对Model进行增强,发现拦截器执行了两次
@JFinal 你好,想跟你请教个问题:
在JFinal2.1中尝试对Model(User)进行增强,发现拦截器(ModelInterceptor.java)执行了两次,能否分析下是什么原因。
User.java
/** * Generated by JFinal. */ @SuppressWarnings("serial") public class User extends BaseUser<User> { //public static final User dao = new User(); public static final User dao = Enhancer.enhance(User.class, ModelInterceptor.class); public Page<User> paginate(int pageNumber, int pageSize) { return paginate(pageNumber, pageSize, "select *", "from pt_user order by ids asc"); } }
@Before(UserValidator.class) public void getUserListpaginate() { renderJson("result", User.dao.paginate(getParaToInt("pageNumber"), getParaToInt("pageSize"))); }
ModelInterceptor.java
public class ModelInterceptor implements Interceptor { @Override public void intercept(Invocation invoc) { invoc.invoke(); System.out.println("dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); } }
执行结果
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
JFinal action report -------- 2016-01-07 17:57:18 ------------------------------
Controller : com.platform.mvc.user.UserController.(UserController.java:1)
Method : getUserListpaginate
Interceptor : com.platform.config.run.GlobalInterceptor.(GlobalInterceptor.java:1)
com.jfinal.plugin.activerecord.tx.TxByMethods.(TxByMethods.java:1)
com.jfinal.plugin.activerecord.tx.TxByMethodRegex.(TxByMethodRegex.java:1)
com.platform.mvc.user.UserValidator.(UserValidator.java:1)
--------------------------------------------------------------------------------
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论