关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
?
?
?
?
?
?
?
?
?
?
?
http://www.springframework.org/schema/context/spring-context.xsd。这里我们可以打开这个Schema的位置,下面是这个文档的开始部分:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="xxx.xxx.controller" />
<context:annotation-config/>
<mvc:default-servlet-handler/>
<mvc:annotation-driven/>
<mvc:resources mapping="/images/**" location="/images/" />
<bean id="xxx" class="xxx.xxx.xxx.Xxx">
<property name="xxx" value="xxxx"/>
bean>
beans>
|
| 1 2 3 4 5 6 |
<table>
<tr>
<td>Applestd>
<td>Bananastd>
tr>
table>
|
和描述一张桌子的:
| 1 2 3 4 5 |
<table>
<name>African Coffee Tablename>
<width>80width>
<length>120length>
table>
|
| 1 |
xmlns:context="http://www.springframework.org/schema/context"
|
| 1 |
<context:component-scan base-package="xxx.xxx.controller" />
|
| 1 |
xmlns:abc="namespaceURI"
|
| 1 2 3 4 5 6 7 |
<h:table xmlns:h="url1">
<h:tr>
<h:td>Applesh:td>
<h:td>Bananash:td>
h:tr>
h:table>
|
| 1 2 3 4 5 6 |
<f:table xmlns:f="url2">
<f:name>African Coffee Tablef:name>
<f:width>80f:width>
<f:length>120f:length>
f:table>
|
| 1 |
xmlns="http://www.springframework.org/schema/beans"
|
| 1 2 3 |
<bean id="xxx" class="xxx.xxx.xxx.Xxx">
<property name="xxx" value="xxxx"/>
bean>
|
| 1 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| 1 2 |
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
|
| 1 2 3 4 5 6 7 8 9 |
<xsd:schema xmlns="http://www.springframework.org/schema/context"
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/context"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
|
有了上面的说明后,再去理解开始的Spring XML文档,一定会有不一样的感觉!
最后再次感谢各位前辈的宝贵经验。