如果要直接返回Beetl的 View 对象怎么写? 谢谢!
6 回复
因为BeetlView需要WebRender实例,而只有BeetlViewMaker持有了这个实例, 所以呢,变通一下.
继承BeetlViewMaker,通过静态方法暴露之
package net.wendal.nutzbook.beetl;
import java.io.IOException;
import org.beetl.ext.nutz.BeetlView;
import org.beetl.ext.nutz.BeetlViewMaker;
import org.beetl.ext.web.WebRender;
import org.nutz.mvc.View;
/**
演示如何暴露BeetlViewMaker的WebRender实例,从而生成BeetlView实例.
*/
public class BeetlViewMaker3 extends BeetlViewMaker {
static WebRender _render;
public BeetlViewMaker3() throws IOException {
super();
_render = render;
}
public static View make(String dst) {
return new BeetlView(_render, dst);
}
}
添加回复
请先登陆