我正在用Spring Security模塊開發Spring應用程序。 基本設置工作得很好,但是當我想讓一些邏輯像「FormLogin頁面是唯一允許任何人使用的,只有當用戶通過身份驗證時才能看到所有其他人。」 所以我的spring配置文件是這樣的:彈簧驗證過濾器模式
<security:http security="none" pattern="/resources/**" />
<security:http security="none" pattern="/FormLogin" />
<security:http auto-config="true" use-expressions="true">
<security:csrf disabled="true" />
<security:intercept-url pattern="/**"
access="isAuthenticated()" />
<security:intercept-url pattern="/admin/**"
access="hasRole('Admin')" />
<security:logout logout-success-url="/welcome"
logout-url="/logout" />
<security:form-login login-page="/FormLogin"
login-processing-url="/j_spring_security_check" default-target-url="/welcome"
username-parameter="username" password-parameter="hashPwd"
authentication-failure-url="/loginError" />
</security:http>
所以基本上我有我的管理文件夾中保留的管理員,可以由任何人都只能通過身份驗證的用戶可以看到其他頁面被訪問的FormLogin
沒有這個。 line:
<security:intercept-url pattern="/**" access="isAuthenticated()" />
登錄後,我得到了正確的重定向到歡迎頁面,這樣我重定向到應用程序的根,我得到以下信息:
22/06/2015 20:44:50 - DEBUG - (AbstractSecurityInterceptor.java:242) - Authorization successful
22/06/2015 20:44:50 - DEBUG - (AbstractSecurityInterceptor.java:255) - RunAsManager did not change Authentication object
22/06/2015 20:44:50 - DEBUG - (FilterChainProxy.java:309) -/reached end of additional filter chain; proceeding with original chain
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:861) - DispatcherServlet with name 'spring-mvc' processing GET request for [/Fantacalcio/]
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:294) - Looking up handler method for path/
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:302) - Did not find handler method for [/]
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:294) - Looking up handler method for path/
22/06/2015 20:44:50 - DEBUG - (AbstractHandlerMethodMapping.java:302) - Did not find handler method for [/]
22/06/2015 20:44:50 - DEBUG - (AbstractUrlHandlerMapping.java:123) - Mapping [/] to HandlerExecutionChain with handler [or[email protected]92464f] and 1 interceptor
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:947) - Last-Modified value for [/Fantacalcio/] is: -1
22/06/2015 20:44:50 - DEBUG - (DispatcherServlet.java:1241) - Rendering view [org.springframework.web.servlet.view.JstlView: name 'FormLogin'; URL [/WEB-INF/views/FormLogin.jsp]] in DispatcherServlet with name 'spring-mvc'
22/06/2015 20:44:50 - DEBUG - (InternalResourceView.java:166) - Forwarding to resource [/WEB-INF/views/FormLogin.jsp] in InternalResourceView 'FormLogin'
22/06/2015 20:44:50 - DEBUG - (FrameworkServlet.java:996) - Successfully completed request
22/06/2015 20:44:50 - DEBUG - (ExceptionTranslationFilter.java:116) - Chain processed normally
22/06/2015 20:44:50 - DEBUG - (SecurityContextPersistenceFilter.java:105) - SecurityContextHolder now cleared, as request processing completed
我在做什麼錯?
這看起來不錯,這是什麼問題? – Stefan
而不是被重定向到/歡迎我被重定向到/ – lateralus