Spring框架配置java web實現(xiàn)實例化
java_web的IOC的初始化,是在初始化Tomcat時自動配置
配置spring-web。jar(spring.web包)提供的監(jiān)聽器,此監(jiān)聽器樂意在服務器啟動是初始化IOC容器
初始化Ioc容易(applicationcontext.xml)
1、必須告訴監(jiān)聽器此容易的位置:context_param
2、使用默認約定位置,applicationContext.xml必須放在WEB-INF下面且名字必須是這個名字
代碼如下
<?xml version='1.0' encoding='UTF-8'?><web-app xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://java.sun.com/xml/ns/javaee' xsi:schemaLocation='http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd' version='2.5'> <display-name>web_1</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- 指定IOc容器的位置 --> <context-param> <!-- 監(jiān)聽器的父類中 一個屬性contextConfigLocation,該屬性保存著容器配置文件applicationcontext.xml的位置--> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <!-- 配置spring-web。jar提供的監(jiān)聽器,此監(jiān)聽器樂意在服務器啟動是初始化IOC容器 初始化Ioc容易(applicationcontext.xml),1、必須告訴監(jiān)聽器此容易的位置:context_param 2、使用默認約定位置,applicationContext.xml必須放在WEB-INF下面且名字必須是這個名字 --> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener></web-app>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關文章:
1. chat.asp聊天程序的編寫方法2. JSP之表單提交get和post的區(qū)別詳解及實例3. 利用FastReport傳遞圖片參數(shù)在報表上展示簽名信息的實現(xiàn)方法4. PHP循環(huán)與分支知識點梳理5. Ajax請求超時與網(wǎng)絡異常處理圖文詳解6. JSP+Servlet實現(xiàn)文件上傳到服務器功能7. jsp實現(xiàn)textarea中的文字保存換行空格存到數(shù)據(jù)庫的方法8. ASP中格式化時間短日期補0變兩位長日期的方法9. JavaWeb Servlet中url-pattern的使用10. jsp EL表達式詳解
