@Controller
public class AccountAction extends TsBaseAction {
public AccountAction(){
System.out.println("AccountAction init ========================================");
} @RequestMapping(value="createAccount.action",method= RequestMethod.GET)
public String create(HttpServletRequest request,HttpServletResponse response,ModelMap map){
System.out.println(accountDao);
System.out.println("----accountDao------in get-----------------------------------------------");
AccountDao dao = (AccountDao) ApplicationContextFactory.getInstance().getBean("accountDao");
System.out.println(dao + "---------------------------------------------------------"); return "test/createAccount.jsp";
} @Autowired
AccountDao accountDao;
public void setAccountDao(AccountDao accountDao) {
System.out.println("init accountDao --------------");
this.accountDao = accountDao;
}} 我的控制类 进action没问题 注入也确实注入了
init accountdao 也执行了 但是进create方法以后 accountdao又成null了 后来我又重构了构造函数 发现构造函数AccountAction init 执行了2次 这大概会是什么原因呢 请教 谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货