<?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>
xmlns
xml name space
命名空间, 防止冲突的. =后面就是命名空间的值,整个网址就是值.
xmlns后面不带: 的是默认空间, xml元素不写前缀默认使用这个.
xsi:schemaLocation
后面跟的网址就是xsd或者dtd文件的位置.
XML Schema:
•
定义可出现在文档中的元素
•
定义可出现在文档中的属性
•
定义哪个元素是子元素
•
定义子元素的次序
•
定义子元素的数目
•
定义元素是否为空,或者是否可包含文本
•
定义元素和属性的数据类型
•
定义元素和属性的默认值以及固定值
xsd
Xml Schema Definition
是dtd的替代者
描述xml文档的格式, 有这个之后idea就能自动补全, 因为idea就是靠这个文件知道所有元素的.
XML Schema 是 W3C 标准
XML Schema 是 DTD 的继任者
我们认为 XML Schema 很快会在大部分网络应用程序中取代 DTD。
理由如下:
•
XML Schema 可针对未来的需求进行扩展
•
XML Schema 更完善,功能更强大
•
XML Schema 基于 XML 编写
•
XML Schema 支持数据类型
•
XML Schema 支持命名空间
评论区