使用Spring通过邮件重置密码

问题描述

我已经实现了一种邮寄功能,通过该功能可以向用户发送确认令牌,然后单击提供的URL,然后会打开一个页面,该页面填充了要向其发送电子邮件用户的电子邮件ID。

然后他们可以重置,但是当我尝试使用新密码提交表单时。它没有将值传递给我提供的功能

@PostMapping("/resetUserPassword")
public String accountPasswordReset(@Valid @modelattribute("updateUserPassword") ResetPassword user,BindingResult theBindingResult,Model theModel){
 
//this line outputs null value
System.out.println("accountPasswordReset: email="+user.getEmail());
if(user.getEmail()!=null) {
    User tokenUser = userService.findByEmailIdIgnoreCase(user.getEmail());
    tokenUser.setPassword(passwordEncoder.encode(user.getpassword()));
    userService.save(tokenUser);
    return "successpasswordReset";
        }else {
        return "error";
        }
    }

<form:form action="${pageContext.request.contextpath}/register/resetUserPassword" modelattribute="updateUserPassword" class="form-horizontal" method="POST">
    <!-- Email -->
    <div class="form-group">
    <label for="emailId">Email (*)</label>
    <form:input path="email" id="emailId" placeholder="email (*)"
        class="form-control" disabled="true" readonly="true" />
        <form:errors path="email" cssClass="error" />
        </div>
        
        <!-- Password -->
    <div class="form-group">
    <label for="password">Password (*)</label>
    <form:password path="password" id="password"
    placeholder="password (*)" class="form-control" />
    <form:errors path="password" cssClass="error" />
    </div>
 
    <!-- Reset Button -->
        <div style="margin-top: 10px" class="form-group">
    <div class="col-sm-6 controls">
    <button type="submit" class="btn btn-primary">Reset</button>
    </div>
    </div>
</form:form>

解决方法

我缺少最小的东西,在这一行中,我只是删除了disable =“ true”并有效