日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring命名空间引入方法

發(fā)布時(shí)間:2025/4/14 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring命名空间引入方法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
spring 整合了各種工具,并且spring提供了對(duì)各種工具的xml scheme 的配置方式,簡化了開發(fā)。 但是對(duì)于各種工具的xml命名空間的引入,我一直很郁悶,不知道應(yīng)該怎樣引入,今天經(jīng)過摸索發(fā)現(xiàn)了 對(duì)于各種命名空間的引入的方法,現(xiàn)做以下說明,以加深記憶: <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
????xmlns:aop="http://www.springframework.org/schema/aop"
????xmlns:context="http://www.springframework.org/schema/context"
????xmlns:tx="http://www.springframework.org/schema/tx"
????xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
????????http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
????????http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
????????http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
</beans>
? 首先xmlns="http://www.springframework.org/schema/beans"
????xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
是必須存在的,可以從spring的文檔和例子中查找到, xsi:schemaLocation 指定了用于解析和校驗(yàn)xml的定義文件(xsd)的位置。 我們以添加aop命名空間為例: 在spring.jar文件中的META—INF目錄中提供了spring.schemas 文件,這個(gè)文件指定了提供支持的功能的 xml元素配置的命名空間定義文件的位置,在這個(gè)文件中我們可以找到aop的位置: http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
那么我們可以在spring.jar文件的對(duì)應(yīng)目錄中找到這些xsd文件,打開文件以后, 可以看到標(biāo)簽:<xsd:schema xmlns="http://www.springframework.org/schema/aop"
??xmlns:xsd="http://www.w3.org/2001/XMLSchema"
??xmlns:beans="
http://www.springframework.org/schema/beans"
??xmlns:tool="
http://www.springframework.org/schema/tool"
??targetNamespace="
http://www.springframework.org/schema/aop"
??elementFormDefault="qualified"
??attributeFormDefault="unqualified">
那么第一個(gè)xmlns就是要引進(jìn)的命名空間,但是在引進(jìn)applicationContext.xml之前需要修改為: xmlns:aop="http://www.springframework.org/schema/aop",之后添加入applicationContext.xml文件中,且一定要放置于xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"之后,順序不能錯(cuò)。 之后需要在xsi:schemaLocation 中添加位置:
http://www.springframework.org/schema/aop(空格)http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
而/spring-aop-2.5.xsd就是aop的元素的定義的文件名

轉(zhuǎn)載于:https://www.cnblogs.com/Neil223/p/5759780.html

總結(jié)

以上是生活随笔為你收集整理的Spring命名空间引入方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。