NutzCN Logo
问答 nutz重定向beetl问题
发布于 2560天前 作者 1037424761 1507 次浏览 复制 上一个帖子 下一个帖子
标签:
@Ok("beetl:/platform/yd/wx/order.html")

一般在方法结束时,就可以跳转到我要的页面,但是我现在要在ActionFilter实现类中使用

@Override
	public View match(ActionContext context) {
		String openid = Strings.sNull(context.getRequest().getSession().getAttribute("openid"));
        if (cloudBindService.count(Cnd.where("id","=",openid))<=0) {
        	return new ForwardView(path);
        }
		return null;
	}

单纯的将具体路径赋值到path中可以跳转,但是无法beetl没有渲染,求指教该怎么改?

3 回复

我猜你纠结的链条是这样的

要渲染成BeetlView,所以需要new BeetlView,但它的构造需要WebRender,而这个对象是BeetlViewMaker持有的,是它的一个public属性,你找不到方法取BeetlViewMaker

所以,只要知道了怎么获取BeetlViewMaker,链条就打通了

这个要回到MainSetup的init方法,通过nc.getViewMakers()可以拿到

参考 https://github.com/wendal/nutz-book-project/blob/v3.x/nutzcn-yvr/src/main/java/net/wendal/nutzbook/yvr/YvrMainSetup.java

 @Override
    public void init(NutConfig nc) {
        Ioc ioc = nc.getIoc();
        Daos.createTablesInPackage(nc.getIoc().get(Dao.class), getClass().getPackage().getName() + ".bean", false);
        // 检查一下Ehcache CacheManager 是否正常.
        CacheManager cacheManager = ioc.get(CacheManager.class);
        log.debug("Ehcache CacheManager = " + cacheManager);

        // 设置Markdown缓存
        if (cacheManager.getCache("markdown") == null)
            cacheManager.addCache("markdown");
        Markdowns.cache = cacheManager.getCache("markdown");

        ioc.get(YvrService.class).updateTopicTypeCount();
        ioc.get(AuthorityService.class).initFormPackage(getClass().getPackage().getName());
        
        for (ViewMaker vm : nc.getViewMakers()) {
            if (vm instanceof BeetlViewMaker) {
                ((BeetlViewMaker)vm).groupTemplate.registerFunction("markdown", new MarkdownFunction(ioc.get(PropertiesProxy.class, "conf")));
            }
        }
    }

这个nc,我看了半天,不懂怎么在拦截器中获得?

拿到BeetlViewMaker,然后放到一个public static属性嘛

添加回复
请先登陆
回到顶部