2013-01-02 4 views
0

나는 스프링 보안으로 로그인 페이지를 개발하고 있지만 프로젝트를 시작할 때 자동으로 로그인 페이지로 리디렉션됩니다. index.xhtml로 리디렉션 된 web.xml에 왜 login.xhtml로 리디렉션 되었습니까?스프링 보안 로그인

web.xml을

<web-app > 
<display-name>AirTour</display-name> 

<welcome-file-list> 
    <welcome-file>index.xhtml</welcome-file> 
</welcome-file-list> 

<!-- SPRING --> 

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     /WEB-INF/conf/applicationContext.xml 
    </param-value> 
</context-param> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 
<listener> 
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 
</listener> 

<!-- SPRING SECURITY --> 


<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 



<!-- JSF --> 

<context-param> 
    <param-name>javax.faces.PROJECT_STAGE</param-name> 
    <param-value>Development</param-value> 
</context-param> 

<servlet> 
    <servlet-name>Faces Servlet</servlet-name> 
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name> 
    <url-pattern>*.xhtml</url-pattern> 
</servlet-mapping> 
</web-app> 

applicationContext.xml

<bean id="userDetailsManager" class="org.springframework.security.provisioning.JdbcUserDetailsManager"> 
    <property name="dataSource" ref="dataSource"></property> 
</bean> 

<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder"/> 

<bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource"> 
    <property name="userPropertyToUse" value="username"/> 
</bean> 



<security:authentication-manager alias="authenticationManager"> 
     <security:authentication-provider user-service-ref="userDetailsManager"> 
     <security:password-encoder ref="passwordEncoder"> 
      <security:salt-source ref="saltSource"/> 
     </security:password-encoder> 
     </security:authentication-provider> 
</security:authentication-manager> 

<security:http > 
    <security:intercept-url pattern="/user/*" access="ROLE_USER"/> 
    <security:intercept-url pattern="/comp/*" access="ROLE_COMP"/> 
    <security:intercept-url pattern="/admin/*" access="ROLE_ADMIN"/> 
    <security:intercept-url pattern="/*" access="ROLE_ANONIMOUS,ROLE_USER,ROLE_COMP,ROLE_ADMIN"/> 

    <security:form-login login-page="/login"/> 
</security:http> 

답변

0

당신이 당신의 봄 보안 설정에서 맞춤법 실수를 한 것 같습니다. ROLE_ANONYMOUSROLE_ANONIMOUS 교체 :

<security:intercept-url pattern="/*" access="ROLE_ANONYMOUS,ROLE_USER,ROLE_COMP,ROLE_ADMIN"/> 
+0

고맙지 만 문제는 동일합니다. – pasteles

+0

@pasteles 로그인 페이지로 리디렉션되는 URL은 무엇입니까? –

0
이 마지막 intercept-url이로 변경

:

<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" /> 

또한 security:httpauto-config를 사용합니다.

<security:http auto-config="true"> 
관련 문제