我有加入的Apache四郎該JSF 2.0 /春季應用和重定向後會話超時不會發生當上的命令按鈕用戶點擊或觸發一個AJAX請求。它在刷新瀏覽器時工作。這發生在所有瀏覽器中。這是我的applicationContext.xml:JSF 2 +彈簧3 +四郎 - 會話超時不重定向到登錄頁面
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/index.faces"/>
<property name="filterChainDefinitions">
<value>
/* = authc
</value>
</property>
</bean>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="opacsRealm" />
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
<bean id="sha512Matcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
<property name="hashAlgorithmName" value="SHA-256" />
<property name="hashIterations" value="1024" />
</bean>
<bean id="opacsRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
<property name="dataSource" ref="dataSource" />
<property name="authenticationQuery"
value="select PASSWORD, SALT from SEC_USERS where NAME = ?" />
<property name="userRolesQuery"
value="SELECT ROLE_NAME FROM SEC_USERS_ROLES WHERE USER_NAME = ?" />
<property name="permissionsQuery"
value="SELECT permission FROM SEC_ROLES_PERMISSIONS WHERE ROLE_NAME = ?" />
<property name="permissionsLookupEnabled" value="true" />
<property name="saltStyle" value="COLUMN" />
<property name="credentialsMatcher" ref="sha512Matcher"/>
</bean>
我在做錯了什麼設置?在web.xml文件看起來是這樣的:
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<!-- web.xml expects the session timeout in minutes: -->
<session-timeout>1</session-timeout>
</session-config>
只是踢,我改變了authc使用自定義FormAuthenticationFilter和推翻的redirectToLogin方法和添加回父類的代碼。沒有改變,但我添加到方法的日誌語句打印,所以重定向正在發生,但瀏覽器從不重定向,除非刷新完成。 –
我沒有給你一個答案,但我可以告訴你,這很可能是事先設計好的。通過這種配置,當會話超時時,authc過濾器會將任何ajax請求重定向到登錄頁面。但是,爲了將頁面刷新到登錄頁面,javascript需要解釋302響應並刷新頁面。這已經四郎用戶列表最近討論,我相信提問者找到一個合適的解決方案:http://shiro-user.582556.n2.nabble.com/Web-Filter-to-return-HTTP-status-code -td7577672.html – jbunting
我剛剛讀到那個謝謝。他沒有回答他的解決方案,所以我會看看我能否從他的帖子中找出答案。 –