Rak*_*yal 5 java xml xml-namespaces
我有一个条目servlet.xml,
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr
Run Code Online (Sandbox Code Playgroud)
现在,我认为,dwr是我们要使用的前缀,比如
<dwr:configuration>
<dwr:convert type="bean" class="com.abc.bean.MyBean" />
</dwr:configuration>
Run Code Online (Sandbox Code Playgroud)
现在问题是,如果网站http://www.directwebremoting.org关闭,那么我的应用程序无法创建bean.
每当beanfactory创建bean时,它会打到这个网站吗?
有没有其他选择,以便我可以使用dwr,而无需访问他们的网站?
完整标题:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
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-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
Run Code Online (Sandbox Code Playgroud)
mar*_*c_s 12
它是一个XML命名空间.这用于确保您的XML标识符(标记等)是唯一的 - 您只需将它们包装在命名空间(如.NET命名空间)中.
名称空间只是一个标识符 - 它不是网络上的真实位置!
XML命名空间必须是唯一的 - 这就是为什么许多公司在命名空间中使用他们的*.com域名,因为没有其他人可以(或应该)使用它.
但是你所拥有的"伪URL" 不是物理URL,即使"www.directwebremoting.org"域名应该关闭或停止,你的代码仍然可以工作!
它只是一个名称 - 只是一个名称 - 没有物理文件驻留在"URL"后面.
更新:好的,我们在这里有一个不同的问题:
<beans xmlns="http://www.springframework.org/schema/beans"
...........
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
==> http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"> <==
Run Code Online (Sandbox Code Playgroud)
这些xsi:schemaLocation条目是罪魁祸首 - 这些当然会导致对该站点的依赖,因为您spring-dwr-2.0.xsd直接通过该站点上的URL 引用XML模式文件().
您当然也可以将这些*.xsd文件下载到本地磁盘并从那里使用它.这样的XML命名空间只不过是一个名称,但是这个schemaLocation http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd显然是一个真实的物理URL,如果站点关闭则无法工作.
问题可能与命名空间本身没有直接关系,而是与此dwr命名空间的架构位置直接相关.
因此,用作命名空间标识符的URI可以是"任何"并且不被访问以处理文件(我们使用基于因特网域的命名空间ID作为具有全局唯一命名空间的便利方式),有效地访问模式位置.
要解决此问题,您可以下载架构,将其发布在可靠的站点上,并更改引用它的XML文件中的架构位置.
"架构"是DTD,或者现在更常见,就像这里的XSD文件一样.实际上,您需要下载以下内容.
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd
Run Code Online (Sandbox Code Playgroud)
然后,您可以在自己的服务器上发布spring-dwr-2.0.xsd(或者如果这些不是在线应用程序,则可以在目录中使用它),并将XML标题中的相应行更改为read(其中) MyOwnDomain等反映了您当前的实际网站):
http://www.directwebremoting.org/schema/spring-dwr
http://www.MyOwnDomain.com/SomeDirectory/spring-dwr-2.0.xsd">
Run Code Online (Sandbox Code Playgroud)
以这种方式,即使directwebremoting.org站点不可用,XML处理逻辑也不会有任何延迟.
注意,有问题的XSD很可能引用其他模式,如果是这种情况,您还需要下载这些模式并确保XSD指向新位置以及这些模式.
| 归档时间: |
|
| 查看次数: |
5850 次 |
| 最近记录: |