简体   繁体   English

Spring Security:如何从 <sec:form-login> 标签

[英]Spring Security: How to get the login-page from the <sec:form-login> Tag

Hi I'm trying to get the login-page value from the <sec:form-login> that can be set in the application-context.xml : 嗨,我正在尝试从<sec:form-login>中获取登录页面值,该值可以在application-context.xml中进行设置:

<beans>
...
<sec:form-login login-page="/login.html" 
    authentication-failure-url="/failed.html"
    default-target-url="/secure/index.jsp" />
...
</beans>

Eg I've got a KerberosFailureHandler which implements the AuthenticationFailureHandler Interface. 例如,我有一个实现AuthenticationFailureHandler接口的KerberosFailureHandler This handler should redirect to the loginpage that is configured in my application-context.xml. 该处理程序应重定向到我的application-context.xml中配置的登录页面。 But I don't know how to get the parameter. 但是我不知道如何获取参数。 Is it possible to inject the value with an @Autowired or something? 是否可以使用@Autowired或其他方式注入值?

I think the normal way to do that would be to extract the login page value to an external configuration (eg properties file, but it could be in .java just as well, especially if you use @Configuration ). 我认为通常的方法是将登录页面值提取到外部配置(例如属性文件,但也可以在.java中,尤其是如果使用@Configuration )。 Then inject the same value into the AuthenticationFailureHandler and the login configuration. 然后将相同的值注入AuthenticationFailureHandler和登录配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM