ZK Spring 整合View/Controller层属性注入
来源:互联网 发布:皮下脂肪怎么减 知乎 编辑:程序博客网 时间:2024/05/21 21:46
问题场景
ZK实例化的View/Controller不同于Spring MVC实例化的Controller,不受Spring管理,无法进行注入。
解决方案
方法一
在doAfterCompose方法中调用SpringUtil提供的获取bean的方法,给bean赋值,代码如下:
userService = (UserService) SpringUtil.getBean("userService");
方法二
在doAfterCompose方法中调用Spring的自动注入方法进行所有bean的注入,此时需要在注入类上面添加@Autowired。代码如下:
SpringUtil.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(this);
备注
ZK提供了针对Spring的Bean管理注解,官方文档给出的例子为,在类上面添加下面注解:
@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
同时,在注入属性上添加下面的注解:
@WireVariableprivate UserService userService;
但官网提供的这种方法经过测试,并没有成功注入,原因还在进一步调查中。
0 0
- ZK Spring 整合View/Controller层属性注入
- 1 Spring MVC View层与Controller层的衔接
- spring boot controller注入提示找不到业务层类
- ASP.NET MVC 整合 Spring.net- Controller注入
- ASP.NET MVC 整合 Spring.net- Controller注入
- spring整合mybatis,dao层类注入不进去
- spring mvc view-controller
- Spring mvc view层循环展示controller层发送的集合对象
- Struts2、Hibernate、Spring整合时如何向Servlet注入属性
- Struts2、Hibernate、Spring整合时如何向Servlet注入属性
- Spring+Servlet整合(如何向Servlet注入属性)
- MVC3 view层和controller层数据传输
- view controller的automaticallyAdjustsScrollViewInsets属性
- DAO层,Service层,Controller层、View层
- DAO层,Service层,Controller层、View层
- DAO层,Service层,Controller层、View层
- DAO层,Service层,Controller层、View层
- DAO层,Service层,Controller层、View层
- HDOJ Choose the best route (最短路倒着构图Dijkstra)
- 【mysql教程】怎样测试MySQL安装
- shell中cp命令
- PHP
- DAO的叫話
- ZK Spring 整合View/Controller层属性注入
- android 多类型表单实现
- leetcode之路041 First Missing Positive
- ASP.NET查找路由表RouteTable中路由名等信息的方法
- 【HDU 5402】Travelling Salesman Problem(构造)
- Oracle ADRCI工具的使用
- ListView异步加载图片
- 拷贝构造函数的参数为什么是引用
- 数据结构基本概念