2013-08-09 5 views
2

로그인 페이지에 표시 할 버튼이 있습니다.스프링 보안을 사용하여 숨기기 요소를 표시하는 방법

그래서 사용자가 로그인하면이 버튼을 숨기고 싶습니다. 나는이 그래서 난 내 JSP

<sec:authorize access="not isAuthenticated()"> 
      <div class="pull-right"> 

에 다음과 같은 것을 포함하지만 로그인 페이지에 표시뿐만 아니라 이후에 기록되지 않습니다에 대한

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

유용

생각합니다.

무엇을 할 수 문제가된다.

<http pattern="/foobar/static-wro4j/**" security="none"/> 
<http pattern="/foobar/static/**" security="none"/> 
<http pattern="/foobar/login*" security="none"/> 
<http pattern="/foobar/syndic/**" security="none"/> 
<http pattern="/foobar/register/**" security="none"/> 
<http pattern="/foobar/lostpassword/**" security="none"/> 

<http auto-config="true" use-expressions="true" create-session="ifRequired"> 
    <remember-me key="foobarRememberKey" token-validity-seconds="2592000"/> 
    <intercept-url pattern="/foobar/presentation" access="permitAll()"/> 
    <intercept-url pattern="/foobar/tos" access="permitAll()"/> 
    <intercept-url pattern="/foobar/license" access="permitAll()"/> 
    <intercept-url pattern="/foobar/404-error" access="permitAll()"/> 
    <intercept-url pattern="/foobar/500-error" access="permitAll()"/> 
    <intercept-url pattern="/foobar/rest/users" method="POST" access="permitAll()"/> 
    <intercept-url pattern="/metrics/**" access="hasRole('ROLE_ADMIN')"/> 
    <intercept-url pattern="/**" access="isAuthenticated()"/> 

    <form-login 
      login-processing-url="/foobar/authentication" 
      login-page="/foobar/login" 
      authentication-failure-url="/foobar/login?action=loginFailure" 
      default-target-url="/foobar/" 
      authentication-success-handler-ref="foobarAuthenticationSuccessHandler"/> 
    <http-basic/> 
    <logout logout-url="/foobar/logout" 
      logout-success-url="/foobar/login"/> 

    <openid-login authentication-failure-url="/foobar/login?action=loginFailure" 
        user-service-ref="openIdAutoRegisteringUserDetailsService"> 
     <!-- Only Google Apps is supported --> 
     <attribute-exchange identifier-match="https://www.google.com/.*"> 
      <openid-attribute name="email" type="http://axschema.org/contact/email" required="true" count="1"/> 
      <openid-attribute name="firstname" type="http://axschema.org/namePerson/first" required="true"/> 
      <openid-attribute name="lastname" type="http://axschema.org/namePerson/last" required="true"/> 
     </attribute-exchange> 
    </openid-login> 
</http> 
+0

당신은 여전히 ​​hav 전자 문제가 귀하의 설정을 게시합니다. –

+0

여전히 access = "isAnonymous() not working ... –

답변

5

당신이 JSP에서 봄 보안 태그 라이브러리 포함했는지 확인하십시오 : 보안 구성에서

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 

은 다음과 같습니다

:

<beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/> 

는 그 다음 authorize 태그를 사용을

<sec:authorize access="isAuthenticated()"> 
    <!-- Content for Authenticated users --> 
</sec:authorize> 

<sec:authorize access="isAnonymous()"> 
    <!-- Content for Unauthenticated users --> 
</sec:authorize> 
+0

conf에'' 태그를 사용하면 명시 적으로 'DefaultWebSecurityExpressionHandler'를 선언 할 필요가 없습니다. –

관련 문제