Spring安全拦截方法显示错误

时间:2015-04-15 10:59:58

标签: spring spring-mvc spring-security spring-security-ldap spring-security-acl

    <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:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

<bean id="messageBoardService" 
    class="com.service.MessageBoardServiceImpl">
    <security:intercept-methods>
    <security:protect 
        method="com.service.MessageBoardService.listMessages"
        access="ROLE_USER,ROLE_GUEST" />
    <security:protect 
        method="com.service.MessageBoardService.postMessage"
        access="ROLE_USER" />
    <security:protect 
        method="com.service.MessageBoardService.deleteMessage"
        access="ROLE_ADMIN,IP_LOCAL_HOST" />
    <security:protect 
        method="com.service.MessageBoardService.findMessageById"
        access="ROLE_USER,ROLE_GUEST" />
    </security:intercept-methods>
</bean>

通过执行上面的代码行显示错误

匹配的通配符是strict,但是找不到元素'bean'的声明

并在安全拦截方法标记

上显示红色下划线

这里是jar文件列表enter image description here

1 个答案:

答案 0 :(得分:0)

添加到xml文件时的此标头。它的工作正确

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">