spring security3 配置登录页面不过滤的时候报错


最近在看spring security 3.自己搭了安装文档搭了一个小demo,就是模拟登录拦截
采用版本是3.2.5
下面是xml命名空间


 <beans 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:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xmlns:security="http://www.springframework.org/schema/security" 
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://code.alibabatech.com/schema/dubbo 
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/security   
        http://www.springframework.org/schema/security/spring-security-3.2.xsd">


 <!--  标识所有的请求都会被拦截只有角色 ROLE_USER能访问 -->
    <security:http auto-config="true">
        <security:intercept-url pattern="/**" access="ROLE_USER"/>
        <!-- 标识login.jsp页面无需被过滤 之所以带星号是因为页面在请求的时候可能会带有参数  3.1以上不再支持filters 所以采用security-->
        <security:intercept-url pattern="/login.jsp*" filters="none"/>
        <!-- 如果被拦截直接转发到自定义的登录页面 -->
        <security:form-login login-page="/login.jsp"/>
    </security:http>

上是原有的配置,根据文档来走的,但是程序报错,说已经不支持filters建议采用security,网上查了许多的列子也是这样所的,于是修改代码如下:


 <!--  标识所有的请求都会被拦截只有角色 ROLE_USER能访问 -->
    <security:http auto-config="true">
        <security:intercept-url pattern="/**" access="ROLE_USER"/>
        <!-- 标识login.jsp页面无需被过滤 之所以带星号是因为页面在请求的时候可能会带有参数  3.1以上不再支持filters 所以采用security-->
        <security:intercept-url pattern="/login.jsp*" security="none"/>
        <!-- 如果被拦截直接转发到自定义的登录页面 -->
        <security:form-login login-page="/login.jsp"/>
    </security:http>

结果程序还是报错说:
'security' is not allowed to appear in element 'security:intercept-url'.
请问怎么解!

java 安全 spring-security javaweb spring

kukul 9 years ago

各位大侠,难道木有知道的咩,还是我的问题提的不够详细

shikii answered 9 years ago

Your Answer