-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxmlSample.xml
More file actions
48 lines (39 loc) · 2.33 KB
/
Copy pathxmlSample.xml
File metadata and controls
48 lines (39 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> -->
<beans
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
>
<!--
// xml遵循的标签规范
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
// xmlns默认的namespace(beans)
xmlns="http://www.springframework.org/schema/beans"
// xmlns:aop/tx/jee/context 对应的namespace,自定义namespace的作用是相同名字的标签不会冲突,因为有对应的前缀,如<aop:xxx />等
// 另一个作用就是将不同的功能的标签用不同的namespace分开,利于管理和引用,相当于模块化
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
// xsi:schemaLocation
// aop/tx/jee/context 的namespace 所对应的xmlschema的地址,也就是xml书写时需要遵循的语法
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd -->
<!-- 如果是默认的namespace(beans)的标签,那直接写就可以了,如: -->
<bean id="xxx" class="xxx"/>
<!-- 如果是非默认的namespace,如aop/tx/jee/context,那就要这么写对应的标签: -->
<aop:xxx a="1" b="2" />
<tx:xxx a="1" b="2" />
<jee:xxx a="1" b="2" />
<context:xxx a="1" b="2" />
</beans>