XML(Extensible Markup Language)可扩展标记语言
1.xml声明
<?xml version="1.0" encoding="UTF-8"?>
文件符合xml1.0规范,文字编码为UTF-8
2.命名空间
当我们使用不同文档的相同标签时会发生冲突,使用命名空间来避免冲突。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
</beans>
xmlns全称xmlnamespace。
上述指定了4个命名空间,包括一个默认命名空间xmlns=”http://www.springframework.org/schema/beans”,还有xmlns:mvc,xmlns:context,xmlns:xsi。
xmlns:xsi命名空间拥有一个xsi:schemaLocation属性,该属性可以指定命名空间的xsd文件,如上述xsi:schemaLocation属性的前两行将命名空间xmlns=”http://www.springframework.org/schema/beans”的xsd地址指定为http://www.springframework.org/schema/beans/spring-beans.xsd。