问题描述
我想与Spring Boot登录页面创建自定义通信(例如,我不希望在提供错误的凭据后重新加载页面),但是我不知道该怎么做。
在其他页面中,我有一个按钮可通过AJAX传达我的应用程序:
button.click(function(e){
//some magic
$ajax.({
//some more magic
}).done(responseObj => {
//some magic with response
});
})
然后在//some magic with response
中,我可以根据响应值更改页面上的某些组件,例如在密码更改页面上,我可以在屏幕中间显示jumbotron,该密码无法更改,因为提供的旧密码不等于现有密码。假设我想对登录页面做类似的事情,但是在这里(当用户提供错误的凭据时),我想让jumbotron证明凭据无效。问题是我无法访问单击按钮时发生的情况。我有WebSecurityConfigurerAdapter
代码:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
//some not needed code
.formLogin()
.loginPage("/guest/login")
//some more not needed code
}
和登录表单代码:
<form method="post">
<input type="text" name="username" class="form-control" id="inputLogin" placeholder="Login">
<input type="password" name="password" class="form-control" id="inputPassword" placeholder="Password">
<input id="buttonLogin" type="submit" value="Login" class="btn btn-primary float-right">
</form>
而且我不会(甚至我无法)对下面发生的事情做任何事情。我怀疑我需要从上面的代码中删除method="post"
,但是那时我不知道如何与Spring Boot登录逻辑进行通信。有人可以向我解释吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)