Spring security 目的<;豆>;在applicationContext-security.xml中

Spring security 目的<;豆>;在applicationContext-security.xml中,spring-security,Spring Security,新手问题。。。在applicationContext-security.xml中的实际安全设置之前定义的bean的用途是什么 <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:

新手问题。。。在applicationContext-security.xml中的实际安全设置之前定义的bean的用途是什么

<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
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-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

因为此文件将声明spring security的配置。如果您有自定义实现,那么必须将它们作为bean注入。这与默认配置无关,但与自定义实现相关。有关自定义实现的更多详细信息,请遵循以下步骤


此根标记允许您省略文件中的
安全:
前缀(标准,您可以使用任何人)。例如,您将编写:


而不是:


另一方面,你必须写:


而不是:


总而言之,它将文件定位在
安全:
命名空间中,而不是
bean:
命名空间中(例如)。

bean告诉XML解析器文档的内容

它通过引用将在文档中使用的不同属性(前缀为
xmlns
的属性)来实现。它们中的每一个都可以定义文档中允许哪些元素以及如何对其进行验证

xsi:schemaLocation
建议解析器在哪里找到每个名称空间的定义(),以便它可以使用它进行验证


中的前缀表示元素属于哪个名称空间。每个XML文档都可以声明多个名称空间,这有助于解析器判断哪一个名称空间是其中的元素部分。

这两个名称空间实际上是整个代码块。