老师能讲一下命名空间的原理和作用吗
来源:1-4 SpringMVC环境配置-1
幻126
2020-09-13 00:06:07
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/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">
1回答
同学你好,1. XML的元素名字是不固定的,当两个不同的文档使用同样的名称描述两个不同类型的元素的时候,或者一个同样的标记表示两个不同含义的内容的时候,就会发生命名冲突。所以可以通过XML 命名空间避免元素命名冲突的方法。
2. xmlns 属性可以在文档中定义一个或多个可供选择的命名空间。该属性可以放置在文档内任何元素的开始标签中。该属性的值类似于 URL,它定义了一个命名空间,浏览器会将此命名空间用于该属性所在元素内的所有内容。。如课程中的xmlns:mvc,就可以获取mvc下的内容。
3. 关于XML命名空间的原理,同学可以在后期深入了解一下底层代码,现阶段知道命名空间如何使用即可。
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
相似问题