【发布时间】:2012-02-10 09:41:36
【问题描述】:
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.1.xsd">
<context:component-scan
base-package="com.springinaction.chapter01.knight" />
</beans>
上面的例子显示了一个带有多个命名空间的 XML 文件的例子。这些命名空间的目的是什么?最重要的是,为什么它们即使在没有 Internet 连接的情况下也能工作?
我认为以xsi:schemaLocation 开头的第二位包含用于验证 XML 文档结构的 XML 模式文件。如果我在不在网络上的机器上运行使用此配置文件的应用程序,这些为什么仍然有效?这些 URL 是否是 JAR 文件的别名?
【问题讨论】:
标签: java xml spring xsd xml-namespaces