5

我的 , 中有一个servlet.xml条目

xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr

现在,我认为dwr是我们要使用的前缀,比如

<dwr:configuration>
    <dwr:convert type="bean" class="com.abc.bean.MyBean" />
</dwr:configuration>

现在的问题是,如果站点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"> 
4

3 回答 3

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">   <==

这些xsi:schemaLocation条目是罪魁祸首——这些当然会导致对该站点的依赖,因为您是spring-dwr-2.0.xsd通过该站点上的 URL 直接引用 XML 模式文件 ( )。

您当然也可以将这些 *.xsd 文件下载到本地磁盘并从那里使用它。这样的 XML 命名空间只不过是一个名称,但这个 schemaLocationhttp://www.directwebremoting.org/schema/spring-dwr-2.0.xsd显然是一个真实的物理 URL,如果站点关闭,它将无法工作。

于 2009-10-12T06:03:32.763 回答
8

问题可能与命名空间本身没有直接关系,而是与这个 dwr 命名空间的模式位置有关。

因此,用作命名空间标识符的URI可以是“任何东西”,并且不会被访问来处理文件(我们使用基于 Internet 域的命名空间 ID 作为拥有全局唯一命名空间的便捷方式),从而有效地访问模式位置。

解决此问题,您可以下载架构,将其发布到可靠的站点上,并更改引用它的XML文件中的架构位置。

“模式”是 DTD,或者现在更典型的是,这里是 XSD 文件。实际上,您需要下载以下内容。

  http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd

然后,您可以在自己的服务器上发布 spring-dwr-2.0.xsd(或者,如果这些不是在线应用程序,您可以在目录中提供它),并将 XML 标头中的相应行更改为读取(其中MyOwnDomain 等当然反映了您的实际站点):

   http://www.directwebremoting.org/schema/spring-dwr 
   http://www.MyOwnDomain.com/SomeDirectory/spring-dwr-2.0.xsd">

以这种方式,即使 directwebremoting.org 站点不可用,您的 XML 处理逻辑也不会出现延迟。

注意,有问题的 XSD 很可能引用了其他模式,如果是这种情况,您还需要下载这些模式并确保 XSD 也指向新位置。

于 2009-10-12T06:04:35.743 回答
0

DTD可以是一个模式(也可以是XDR等等)。模式定义了输入 XML 数据的结构(元素、属性、属性数据类型等)。

于 2009-10-12T07:17:36.407 回答