org.xml.sax.saxparseexception;cvc复杂类型.2.4.a:发现以元素“header”开头的无效内容

xt0899hw  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(270)
<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"
  xmlns:aop="http://www.springframework.org/schema/aop"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop.xsd">

    <http pattern="/login.html" security="none">
        <headers></headers>
    </http>

</beans:beans>

这是我的spring-security.xml文件。在服务器中部署时出现以下错误。
org.xml.sax.saxparseexception;行号:22;列数:12;cvc复杂类型.2.4.a:发现以元素开头的内容无效

'{"http://www.sringframework.org/schema/security":headers}'. One of '{
"http://www.springframework.org/schema/security":intercept-url, 
"http://www.springframework.org/schema/security":access-denied-handler, 
"http://www.springframework.org/schema/security":form-login, 
"http://www.springframework.org/schema/security":openid-login, 
"http://www.springframework.org/schema/security":x509, 
"http://www.springframework.org/schema/security":jee, 
"http://www.springframework.org/schema/security":http-basic, 
"http://www.springframework.org/schema/security":logout, 
"http://www.springframework.org/schema/security":session-management, 
"http://www.springframework.org/schema/security":remember-me, 
"http://www.springframework.org/schema/security":anonymous, 
"http://www.springframework.org/schema/security":port-mappings, 
"http://www.springframework.org/schema/security":custom-filter, 
"http://www.springframework.org/schema/security":request-cache, 
"http://www.springframework.org/schema/security":expression-handler}' is expected.

你能请任何人帮我解决这个错误吗?

kuuvgm7e

kuuvgm7e1#

这个 <headers> 标签是在SpringSecurity3.2中添加的。正如错误消息所解释的,在SpringSecurity3.1中 <headers> 中的内容无效 <http> 块它期待着其中一个 <intercept-url> , <access-denied-handler>
请注意,SpringSecurity3.x和4.x已经达到其支持生命周期的终点,因此,理想情况下,您应该升级到SpringSecurity5.x。在撰写本文时,SpringSecurity 5.2.x、5.3.x、5.4.x和5.5.x是受支持的版本。
如果您卡在spring security 3.1上,则无法使用 <headers> 标签。

相关问题