1.有个Java类实现Function接口.
public class Print implements Function {
public String call(Object[] paras, Context ctx) {
Object o = paras[0];
if (o != null) {
try {
System.out.println("nihao");
ctx.byteWriter.write((o.toString()+"function").getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return "";
}
}
paras参数是我们传的,ctx参数是框架传的。
2.
ctx.byteWriter.write((o.toString()+"function").getBytes());
这一段相当于把数据传回页面了。
3. spring配置
<bean name="printFunction" class="beetl.fun