jfinal enjoy 3.5
This commit is contained in:
@@ -26,9 +26,14 @@ import com.jfinal.template.stat.Scope;
|
||||
* SharedMethod
|
||||
*
|
||||
* 用法:
|
||||
* engine.addSharedMethod(object);
|
||||
* engine.addSharedStaticMethod(Xxx.class);
|
||||
* #(method(para))
|
||||
* engine.addSharedMethod(new StrKit());
|
||||
* engine.addSharedStaticMethod(MyKit.class);
|
||||
*
|
||||
* #if (notBlank(para))
|
||||
* ....
|
||||
* #end
|
||||
*
|
||||
* 上面代码中的 notBlank 方法来自 StrKit
|
||||
*/
|
||||
public class SharedMethod extends Expr {
|
||||
|
||||
@@ -48,14 +53,20 @@ public class SharedMethod extends Expr {
|
||||
|
||||
public Object eval(Scope scope) {
|
||||
Object[] argValues = exprList.evalExprList(scope);
|
||||
SharedMethodInfo sharedMethodInfo = sharedMethodKit.getSharedMethodInfo(methodName, argValues);
|
||||
|
||||
// ShareMethod 相当于是固定的静态的方法,不支持 null safe,null safe 只支持具有动态特征的用法
|
||||
if (sharedMethodInfo == null) {
|
||||
throw new TemplateException(Method.buildMethodNotFoundSignature("Shared method not found: ", methodName, argValues), location);
|
||||
}
|
||||
try {
|
||||
return sharedMethodInfo.invoke(argValues);
|
||||
SharedMethodInfo sharedMethodInfo = sharedMethodKit.getSharedMethodInfo(methodName, argValues);
|
||||
if (sharedMethodInfo != null) {
|
||||
return sharedMethodInfo.invoke(argValues);
|
||||
} else {
|
||||
// ShareMethod 相当于是固定的静态的方法,不支持 null safe,null safe 只支持具有动态特征的用法
|
||||
throw new TemplateException(Method.buildMethodNotFoundSignature("Shared method not found: ", methodName, argValues), location);
|
||||
}
|
||||
|
||||
} catch (TemplateException e) {
|
||||
throw e;
|
||||
} catch (ParseException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new TemplateException(e.getMessage(), location, e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user