NutzCN Logo
问答 @Inject什么时候生效
发布于 2298天前 作者 zp8821138 1755 次浏览 复制 上一个帖子 下一个帖子
标签:

用beetl自定义标签,需要注入一个service,但是注入的结果是null,这个该咋搞

@IocBean
public class DictTag extends GeneralVarTagBinding {
	String style,dictType;
	String type = "checkbox";

	@Inject
	MacroService macroService;

	private void init() {
		style = (String)getAttributeValue("style");
		dictType = (String)getAttributeValue("dictType");
		type = (String)getAttributeValue("type");
	}

	@Override
	public void render() {
		init();
		List<Macro> list = macroService.listByDictType(dictType);
		System.out.println(list.size());
	}

}

貌似上面写的是@IocBean不行。。

5 回复

是配置beetl.properties里面的?

是的 TAG.dict =com.xxx.tag.DictTag

或者在MainSetup.init内,通过BeetlViewMaker的groupTemplate.registerTagFactory 也可以

额 我试试 谢谢叫兽。

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