google-code-export / nutz

Automatically exported from code.google.com/p/nutz
Apache License 2.0
1 stars 1 forks source link

表达式引擎中调用方法不支持多个参数的方法? #488

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
问题产生的条件:
通过表达式引擎调用一个类的方法,类的实例、方法的3个参�
��都通过Context设置了,调用的时候出现异常。

发生问题的调用代码:
    public static void main(String[] a) throws Exception{           
        Context context = Lang.context();
        context.set("StringCutter",StringCutter.get());
        setContext("str","关于宁波江东瀚鸿建材有限公司的公司设立登记|2011023758");
        context.set("cutStart","关于");
        context.set("cutEnd1","的公司设立登记");
        System.out.println(Util.eval("StringCutter.cut(str,cutStart,cutEnd1)"));        
    }

///////////////// StringCutter.java
public class StringCutter {

    public static StringCutter get(){
        return new StringCutter();
    }

    public static String cut(String src,String start,String end){
        int idx1=src.indexOf(start);
        if(idx1!=-1){
            if(end==null || end.length()==0)
                return src.substring(idx1+start.length());

            int idx2=src.indexOf(end,idx1+start.length());
            if(idx2!=-1)
                return src.substring(idx1+start.length(),idx2);
        }
        else{
        }
        return null;
    }
}

问题的详细说明:
 只有1个参数的貌似没问题,多个参数的中间用,分割,结果提示: Unexcept symbol "," 

异常堆栈:
Exception in thread "main" org.nutz.el.ElException: Unexcept symbol "," nearby 
: StringCutter.cut(str,
    at org.nutz.el.impl.normalizer.VarNormalizer.normalize(VarNormalizer.java:128)
    at org.nutz.el.impl.NutElAnalyzer.analyze(NutElAnalyzer.java:58)
    at org.nutz.el.impl.normalizer.VarNormalizer.readArgs(VarNormalizer.java:183)
    at org.nutz.el.impl.normalizer.VarNormalizer.normalize(VarNormalizer.java:85)
    at org.nutz.el.impl.NutElAnalyzer.analyze(NutElAnalyzer.java:58)
    at org.nutz.el.El.compile(El.java:105)
    at org.nutz.el.El.compile(El.java:85)
    at org.nutz.el.El.eval(El.java:118)
    at util.Util.eval(Util.java:47)
    at util.Util.main(Util.java:62)

相关日志:

Original issue reported on code.google.com by superhan...@gmail.com on 27 May 2011 at 3:08

GoogleCodeExporter commented 9 years ago
额,这个得看看

Original comment by wendal1985@gmail.com on 3 Jun 2011 at 12:57

GoogleCodeExporter commented 9 years ago
在新版EL实现在,这个问题得到了解决

Original comment by juq...@gmail.com on 30 Jun 2011 at 6:18