struts2读取spring中的bean对象

struts2读取spring中的bean对象:

通过测试:采用IOC/DI注入的效率没有通过getBean获取对象的效率高:



ServletContext sc = ServletActionContext.getServletContext();
  if (sc != null) {
   WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
   if (wac != null) {
    this.xxService = (xxService) wac.getBean("xxService");
    if (xxService != null) {
     System.out.println("-----ok----");
    }
   }
  }

你可能感兴趣的:(struts2)