没有合适的资源?快使用搜索试试~ 我知道了~
自定义标签中@Autowired的属性为null 解决办法:两步 1.新建一个类SpringContext,实现接口ApplicationContextAware; 2.spring.xml中添加<bean id="" class="com............SpringContext"> 3.使用SpingContext.getBean("bean名");获取
资源推荐
资源详情
资源评论
自定义标签中@Autowired的属性为null
解决办法:两步
1.新建一个类SpringContext,实现接口ApplicationContextAware;
public class SpringContext implements ApplicationContextAware {
/**
* context
*/
@Autowired
private static ApplicationContext context;
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
/**
* 获取bean
* @param name
* @return
*/
public static Object getBean(String name) {
return context.getBean(name);
}
/**
* 是否包含bean
* @param name
* @return
*/
解决办法:两步
1.新建一个类SpringContext,实现接口ApplicationContextAware;
public class SpringContext implements ApplicationContextAware {
/**
* context
*/
@Autowired
private static ApplicationContext context;
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
/**
* 获取bean
* @param name
* @return
*/
public static Object getBean(String name) {
return context.getBean(name);
}
/**
* 是否包含bean
* @param name
* @return
*/



















资源评论

- #标题与内容不符
- #内容缺失
- #文件乱码
- #引导二次消费
- #需要密码
- #运行出错
- #毫无价值
- #上传者态度恶劣
- #无法联系上传者
fengxianhua126
- 粉丝: 0
- 资源: 19

上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
已下载
下载帮助

资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
