FileSystemXmlApplicationContext("WebContent/WEB-INF/config/spring/web-application-config.xml"); 那么在触发action时会报错: javax.servlet.ServletException: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [D:Program Filesapache-tomcat-6.0.26binWebContentWEB-INFconfigspringweb-application-config.xml]; nested exception is java.io.FileNotFoundException: WebContentWEB-INFconfigspringweb-application-config.xml (The system cannot find the path specified) 如果改为: ApplicationContext ctx=new
ClassPathXmlApplicationContext("WebContent/WEB-INF/config/spring/web-application-config.xml"); 又会报错: javax.servlet.ServletException: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [WebContent/WEB-INF/config/spring/web-application-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [WebContent/WEB-INF/config/spring/web-application-config.xml] cannot be opened because it does not exist 这是因为调用的是ClassPathXmlApplicationContext,而WebContent/WEB-INF/config/spring/web-application-config.xml并不在classespath路径中。