JFinal2.1中尝试对Model进行增强,发现拦截器执行了两次

hypocrite11 发布于 2016/01/07 17:57
阅读 900
收藏 0

开源之夏第三届火热来袭,高校学生参与赢万元奖金!>>>

@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");
	}
}



UserController.java



@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)
--------------------------------------------------------------------------------




加载中
0
JFinal
JFinal
该评论暂时无法显示,详情咨询 QQ 群:点此入群
JFinal
JFinal
该评论暂时无法显示,详情咨询 QQ 群:点此入群
h
hypocrite11
该评论暂时无法显示,详情咨询 QQ 群:点此入群
0
hyanqing
hyanqing
该评论暂时无法显示,详情咨询 QQ 群:点此入群
0
JFinal
JFinal
该评论暂时无法显示,详情咨询 QQ 群:点此入群
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部
返回顶部
顶部