Browse Source

!42 提取 getAction 方法,方便复写实现自定义路由功能
Merge pull request !42 from fuhai/master

JFinal 6 years ago
parent
commit
a1897f9dca
1 changed files with 13 additions and 1 deletions
  1. 13 1
      src/main/java/com/jfinal/core/ActionHandler.java

+ 13 - 1
src/main/java/com/jfinal/core/ActionHandler.java

@@ -45,6 +45,18 @@ public class ActionHandler extends Handler {
 		this.injectDependency = constants.getInjectDependency();
 		this.controllerFactory = constants.getControllerFactory();
 	}
+
+	/**
+     * 方便子类复写getAction、从而可以实现自定义路由的功能的功能
+	 * 一般情况下,ActionHandler 只需要复写 getAction() 功能就可以了
+     *
+     * @param target
+     * @param urlPara
+     * @return
+     */
+	protected Action getAction(String target, String[] urlPara) {
+        return actionMapping.getAction(target, urlPara);
+    }
 	
 	/**
 	 * handle
@@ -59,7 +71,7 @@ public class ActionHandler extends Handler {
 		
 		isHandled[0] = true;
 		String[] urlPara = {null};
-		Action action = actionMapping.getAction(target, urlPara);
+		Action action = getAction(target, urlPara);
 		
 		if (action == null) {
 			if (log.isWarnEnabled()) {