博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
struts2的action中@Autowired注入为null的解决方案
阅读量:7196 次
发布时间:2019-06-29

本文共 290 字,大约阅读时间需要 1 分钟。

今天遇到类似问题,记录下来以便以后查阅:

@Aspect作用于action,致使action中的@Autowired注入为null的解决方案,以下三种任选一种:
1、去掉@Autowired,改用set,get注入
2、将action纳入spring的ioc管理(struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory)
3、修改Struts.xml文件的属性

Tip:必须在所有使用了dao的地方,包括调用它的servcie都要进行@Autowired注入,否则之后的注入就会失败..

转载地址:http://jcqkm.baihongyu.com/

你可能感兴趣的文章