Browse Source

jfinal 3.6 release ^_^

James 7 years ago
parent
commit
ed54a87816
1 changed files with 17 additions and 2 deletions
  1. 17 2
      src/main/java/com/jfinal/template/stat/ast/Case.java

+ 17 - 2
src/main/java/com/jfinal/template/stat/ast/Case.java

@@ -52,8 +52,8 @@ public class Case extends Stat implements CaseSetter {
 	}
 	
 	boolean execIfMatch(Object switchValue, Env env, Scope scope, Writer writer) {
-		for (Expr expr : exprArray) {
-			Object value = expr.eval(scope);
+		if (exprArray.length == 1) {
+			Object value = exprArray[0].eval(scope);
 			
 			// 照顾 null == null 以及数值比较小的整型数据比较
 			if (value == switchValue) {
@@ -65,6 +65,21 @@ public class Case extends Stat implements CaseSetter {
 				stat.exec(env, scope, writer);
 				return true;
 			}
+		} else {
+			for (Expr expr : exprArray) {
+				Object value = expr.eval(scope);
+				
+				// 照顾 null == null 以及数值比较小的整型数据比较
+				if (value == switchValue) {
+					stat.exec(env, scope, writer);
+					return true;
+				}
+				
+				if (value != null && value.equals(switchValue)) {
+					stat.exec(env, scope, writer);
+					return true;
+				}
+			}
 		}
 		
 		return nextCase != null ? nextCase.execIfMatch(switchValue, env, scope, writer) : false;