城市獵人

          在一網情深的日子里,誰能說得清是苦是甜,只知道確定了就義無反顧
          posts - 1, comments - 7, trackbacks - 0, articles - 89

          配置Spring的方法(轉)

          Posted on 2008-12-16 22:40 sailor 閱讀(824) 評論(0)  編輯  收藏 所屬分類: spring

          1、使用 web.xml 來使 Web 容器加載 Spring

           web.xml :
          通過:
             <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
             </listener-->
          或:
             <servlet>
                <servlet-name>SpringContextServlet</servlet-name>
                <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
             </servlet>
          Web 容器會自動加載 /WEB-INF/applicationContext.xml 初始化 ApplicationContex t實例;
          也可以通過
             <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext-*.xml</param-value>
             </context-param>
          使 Web 容器加載指定名稱路徑的 Spring 配置文件。

          2、通過 struts-config.xml 來使 Web 容器加載 Spring

          struts-config.xml
          通過
              <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
                  <set-property property="contextConfigLocation"
                      value="/WEB-INF/applicationContext.xml,
                             /WEB-INF/action-servlet.xml"/>
              </plug-in>
          來加載 Spring 配置文件。


          文章出處:http://www.diybl.com/course/3_program/java/javashl/200855/112963.html

          主站蜘蛛池模板: 崇文区| 临沧市| 都安| 尚义县| 文昌市| 嘉义县| 临江市| 郯城县| 石棉县| 修文县| 绿春县| 隆回县| 宣威市| 宁陵县| 永清县| 平昌县| 集贤县| 上饶市| 潮安县| 遂宁市| 扬州市| 东辽县| 弥勒县| 建湖县| 陵川县| 益阳市| 多伦县| 衡南县| 蒲城县| 襄汾县| 驻马店市| 承德市| 海盐县| 福州市| 丰城市| 宁远县| 东平县| 屯昌县| 遂溪县| 资溪县| 济南市|