版本:Spring Security 4.2.3
我需要登录Jsp页面上的一些其他值,例如“ Form Action”。 是否可以在自定义的SuccessHandler或FailureHandler中获取表单bean“ logonForm”。我尝试了自动接线,但这无济于事。有什么建议吗?
自定义登录JSP
<form:form action="userLogon" commandName="logonForm" >
<input type="hidden" name="action" id="action"/>
FailureHandler
public class MyAppAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@Autowired(required=false)
@Qualifier("logonForm")
private LogonForm logonForm;
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
setUseForward(true); // ensure it is a server forward than client redirect
if (authException != null) {
String userId = logonForm.getUserId();
答案 0 :(得分:0)
事实证明更简单,可从API获得登录字段值:
String userId = request.getParameter("userId");
String action= request.getParameter("action");