作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将用户重定向回他们单击登录链接的页面。 (页面对于未经身份验证的用户是只读的,但对于登录用户是可写的。)我如何将用户重定向回他们登录后的位置?
我通过以下链接将用户发送到登录页面:/spring_security_login?redirect=/item5
.登录后,我希望用户被重定向到 /item5
页。但是,它们总是被重定向到 /
页。
这是我正在使用的配置:
<http use-expressions="true">
<intercept-url pattern="/**" access="permitAll" />
<form-login authentication-success-handler-ref="simpleUrlAuthenticationSuccessHandler"/>
</http>
<beans:bean id="simpleUrlAuthenticationSuccessHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/"/>
<beans:property name="targetUrlParameter" value="redirect"/>
</beans:bean>
targetUrlParameter
没有像预期的那样被接走。我正在使用 Spring Security 3.1.4
最佳答案
使用 SimpleUrlAuthenticationSuccessHandler
时应用以下规则:
- If the alwaysUseDefaultTargetUrl property is set to true, the defaultTargetUrl property will be used for the destination.
- If a parameter matching the value of targetUrlParameter has been set on the request, the value will be used as the destination. By default this has the value "spring-security-redirect".
- If the useReferer property is set, the "Referer" HTTP header value will be used, if present.
- As a fallback option, the defaultTargetUrl value will be used.
referer
发送
POST
时在表单登录中请求。通常,您应该编写
referer
登录页面中隐藏字段中的值,以便
referer
参数传送到
spring_security_login
.
关于java - Spring Security targetUrlParameter 不重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17779366/
我正在尝试将用户重定向回他们单击登录链接的页面。 (页面对于未经身份验证的用户是只读的,但对于登录用户是可写的。)我如何将用户重定向回他们登录后的位置? 我通过以下链接将用户发送到登录页面:/spri
我是一名优秀的程序员,十分优秀!