国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Spring框架配置java web實現實例化

瀏覽:151日期:2022-09-02 11:40:23

java_web的IOC的初始化,是在初始化Tomcat時自動配置

配置spring-web。jar(spring.web包)提供的監聽器,此監聽器樂意在服務器啟動是初始化IOC容器

初始化Ioc容易(applicationcontext.xml)

1、必須告訴監聽器此容易的位置: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> <!-- 監聽器的父類中 一個屬性contextConfigLocation,該屬性保存著容器配置文件applicationcontext.xml的位置--> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <!-- 配置spring-web。jar提供的監聽器,此監聽器樂意在服務器啟動是初始化IOC容器 初始化Ioc容易(applicationcontext.xml),1、必須告訴監聽器此容易的位置:context_param 2、使用默認約定位置,applicationContext.xml必須放在WEB-INF下面且名字必須是這個名字 --> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener></web-app>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Java
相關文章:
主站蜘蛛池模板: 吴堡县| 江陵县| 滁州市| 黄大仙区| 法库县| 姜堰市| 米易县| 五家渠市| 隆化县| 友谊县| 瑞安市| 济宁市| 沅陵县| 武平县| 泽州县| 夹江县| 道孚县| 武乡县| 吉木乃县| 聊城市| 韩城市| 冷水江市| 叙永县| 牡丹江市| 遂昌县| 志丹县| 汤原县| 丁青县| 望都县| 宣威市| 和平县| 郎溪县| 夏河县| 丹凤县| 宽甸| 江安县| 康马县| 昌都县| 卢氏县| 财经| 会宁县|