Spring Security -В контексте приложения не удалось найти видимый экземпляр WebSecurityExpressionHandler

У меня возникают проблемы с отображением ссылки на выход из системы на странице JSP, только если пользователь аутентифицирован. Вот исключение, которое у меня есть в этой строке страницы JSP:

<sec:authorize access="isAuthenticated()">

Исключение:

Stacktrace:
....

root cause

javax.servlet.jsp.JspException: No visible WebSecurityExpressionHandler instance could be found in the application context. There must be at least one in order to support expressions in JSP 'authorize' tags.
    org.springframework.security.taglibs.authz.AuthorizeTag.getExpressionHandler(AuthorizeTag.java:100)
    org.springframework.security.taglibs.authz.AuthorizeTag.authorizeUsingAccessExpression(AuthorizeTag.java:58)

Вот мое приложение -контекст -Security.xml:

<http auto-config='true' >
    <intercept-url pattern="/user/**" access="ROLE_User" />
    <logout logout-success-url="/hello.htm" />
</http>

<beans:bean id="daoAuthenticationProvider"
    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
    <beans:property name="userDetailsService" ref="userDetailsService" />
</beans:bean>

<beans:bean id="authenticationManager"
    class="org.springframework.security.authentication.ProviderManager">
    <beans:property name="providers">
        <beans:list>
            <beans:ref local="daoAuthenticationProvider" />
        </beans:list>
    </beans:property>
</beans:bean>

<authentication-manager>
    <authentication-provider user-service-ref="userDetailsService">
        <password-encoder hash="plaintext" />
    </authentication-provider>
</authentication-manager>

Я понимаю, что мог бы использовать use -expression="true" в теге http, но это означает, что мне пришлось бы использовать выражение в тегах URL-адресов перехвата -и в коде Java. Есть ли обходной путь?

20
задан Shaun the Sheep 21 July 2012 в 18:56
поделиться