隨筆-26  評(píng)論-44  文章-20  trackbacks-0
          在web.xml中配置spring的contextconfigloaction時(shí),總是定位不到src/applicationContext.xml或者
          /src/applicationContext.xml(也許是我不懂父目錄當(dāng)前目錄之類的)。算了,直接刪除這個(gè)context-param,把a(bǔ)pplicationContext.xml文件復(fù)制到web-info下面,反正spring默認(rèn)的就是那里。
          要是剛開始myeclipse自動(dòng)生成的applicationContext.xml文件的位置就在web-info下就不什么事都沒了,不知道把它放到src有什么意圖?

          我暈啊,后來,程序還要到src下找applicationContext.xml文件,web-info下的也不能刪,無語了。

          我發(fā)布到tomcat的時(shí)候,是以WebRoot為根目錄的,即tomcat的server.xml中是這樣配置的:
          <Context path="" docBase="D:\spring_religionMIS\WebRoot"/>
          這也許就是定位不到src/..的原因吧,因?yàn)槌绦蚩偸菑腤ebRoot往下找,當(dāng)然找不到,我又用../src/applicationContext.xml定位也找不到,不知錯(cuò)在哪里?
          posted on 2008-11-04 17:27 開機(jī) 閱讀(2188) 評(píng)論(2)  編輯  收藏 所屬分類: spring

          評(píng)論:
          # re: spring applicationContext文件的位置 2008-11-06 15:34 | sclsch
          放到src下,布署后是在classes目錄下。
          加載spring配置文件還是放到src下比較好。
          <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>
          classpath:applicationContext-hibernate.xml,
          classpath:applicationContext-dao.xml,
          classpath:applicationContext-service.xml,
          classpath:applicationContext-struts.xml
          </param-value>
          </context-param>
          。。。
          <listener>
          <listener-class>
          org.springframework.web.context.ContextLoaderListener
          </listener-class>
          </listener>  回復(fù)  更多評(píng)論
            
          # re: spring applicationContext文件的位置 2008-11-06 20:36 | 開機(jī)
          @sclsch
          謝謝你的建議,我現(xiàn)在src下的已經(jīng)刪了,只留了web-info下的配置文件。
          你的做法很好,用classpath應(yīng)該定位的到,以前只看到程序里面用,沒想到配置文件里也可以用它來定位。  回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 邵东县| 鹿邑县| 河曲县| 淳化县| 紫阳县| 顺昌县| 河池市| 巴南区| 府谷县| 东乡| 林口县| 界首市| 崇明县| 拜泉县| 河曲县| 深水埗区| 龙山县| 泰来县| 永寿县| 神农架林区| 镇巴县| 永州市| 安庆市| 大厂| 双峰县| 定州市| 尉犁县| 余姚市| 远安县| 宜黄县| 阜城县| 平湖市| 灵武市| 宜兴市| 阳西县| 蒙山县| 宝鸡市| 孟连| 怀安县| 万安县| 成武县|