浏览 5289 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-07-25
现在我使用了一个plugin--〉spring-web.jar 我在 spring in action中看到可以这样 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/training-servlet.xml,/WEB-INF/…"/> </plug-in> 把这段配置加入到struts-config.xml文件中,然后用contextConfigLocation来管理每一个action对应的service。 然后我尝试启动工程,结果就出异常。 然后我又尝试在类中new一个contextConfigLocation对象,结果也抛异常。 请教大家。谢谢。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-07-26
会不会是spring-web.jar 和我的spring.jar版本不同呢?
|
|
返回顶楼 | |
发表时间:2005-07-26
你的value="/WEB-INF/training-servlet.xml,/WEB-INF/…"是否存在
|
|
返回顶楼 | |
发表时间:2005-07-26
哦,这里我是拷贝的spring in action的内容。
不过我的配置文件中value确实是存在的。 |
|
返回顶楼 | |
发表时间:2005-07-26
可能是我没有说明白,我再描述一下。
我的lib里边 spring.jar; spring-web.jar; …… 其它jar 以前我们自己写了一个plugin来实例化service。 现在想用spring自带的功能来管理service。于是就调用了spring-web.jar。改了struts-config.xml文件,加上了上面的一段话。在工程启动的时候就抛init异常。 |
|
返回顶楼 | |
发表时间:2005-08-29
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/spring-config.xml" /> </plug-in> 只要一个"/WEB-INF/spring-config.xml"就可以了,那个省略号是不能写在实际用的xml文件中的. |
|
返回顶楼 | |
发表时间:2005-08-30
我说一下我的做法,我的applicationContext-hibernate.xml直接放在src根目录下。在web.xml中调用一个servlet。就叫StartupSpring! 它的构造函数中就执行AppContext.getInstance(); 就样服务器在启动时就会初始化spring中DAO和对应的serviceImpl
public class AppContext { private static AppContext instance; private AbstractApplicationContext appContext; public synchronized static AppContext getInstance() { if (instance == null) { instance = new AppContext(); } return instance; } private AppContext() { this.appContext = new ClassPathXmlApplicationContext( "/applicationContext-hibernate.xml"); } public AbstractApplicationContext getAppContext() { return appContext; } } |
|
返回顶楼 | |