Spring 在我的操作和服务类中避免使用applicationContext.xml
我正在使用Struts和Spring框架编写一个web应用程序。 在Struts操作中,我注入服务类如下Spring 在我的操作和服务类中避免使用applicationContext.xml,spring,struts,Spring,Struts,我正在使用Struts和Spring框架编写一个web应用程序。 在Struts操作中,我注入服务类如下 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); loginService = (LoginService)context.getBean("loginService"); 如何避免在我必须使用的操作类中提到applic
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
loginService = (LoginService)context.getBean("loginService");
如何避免在我必须使用的操作类中提到applicationContext.xml
loginService=(loginService)context.getBean(“loginService”);没有在我的类中指定.xml文件
我在谷歌搜索时发现了下面的用法
私有LoginService LoginService=(LoginService)ApplicationContextProvider.getContext().getBean(“LoginService”)
但是我不想在包中使用静态方法getContext()。Spring支持Struts集成 以此为例