平常用到spring时把它的配置文件copy过来就是了,但是最近看看里面的一些代码,有的还不是太明白,请高手们指导指导。 
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:aop=" http://www.springframework.org/schema/aop" 
         xmlns:tx=" http://www.springframework.org/schema/tx" 
         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-2.5.xsd
http://www.springframework.org/schema/aop
                                       http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/mvc
                                       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
                                   
  命名空间到底产生什么作用呢? 后面的schema是不是电脑不联网就不受约束了?还是这些文件已经存在eclipse的某个文件夹里了?因为点击ctrl和左键时能够看到文件内容。 还有配置xml catalog时的具体选项是什么样的呢?是选public  id还是Url呢? 
spring

解决方案 »

  1.   

    命名空间就是等于你在用到这些设置时的标签的前缀名称。例如你的事务管理器声明的命名空间的前缀是tx那么在使用这些关于事务管理器声明的时候就要tx:开头了这个类似于jsp上使用标签库时定义的prefix一样。
    这个schema就是约束这些标签的使用规范,相当于jsp标签库上的uri。在配置public id的时候id只是在IDE工具里的一个标识,具体的还是uri路径即schema文档路径,所以public id是不可重复的,uri则可以。
      

  2.   

    相信很多人都没去想过这个问题,现在仔细去看spring文档的人少了很多文档都有说的:
    http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/extensible-xml.html#extensible-xml-registration