我在春季靴子上出现灰屏时遇到了问题
我知道这将是问题所在的模式
<div class="modal fade" id="changePasswordModal" tabindex="-1" role="dialog" aria-labelledby="changePasswordModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="changePasswordLongModal" >Change user password</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="changePasswordForm" th:object="${passwordForm}" method="post" class="form" role="form">
<input class="form-control" type="hidden" th:field="${passwordForm.id}">
<div class="form-group row">
<label class="col-lg-3 col-form-label form-control-label">Current Password</label>
<div class="col-lg-9">
<input class="form-control" type="password" th:field="${passwordForm.currentPassword}">
<div class="alert-danger" th:if="${#fields.hasErrors('currentPassword')}" th:errors="*{currentPassword}">Password</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label form-control-label">New Password</label>
<div class="col-lg-9">
<input class="form-control" type="password" th:field="${passwordForm.newPassword}">
<div class="alert-danger" th:if="${#fields.hasErrors('newPassword')}" th:errors="*{newPassword}">Password</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label form-control-label">Confirm Password</label>
<div class="col-lg-9">
<input class="form-control" type="password" th:field="${passwordForm.confirmPassword}">
<div class="alert-danger" th:if="${#fields.hasErrors('confirmPassword')}" th:errors="*{confirmPassword}">Confirm Password</div>
</div>
</div>
<div class="col-lg-12">
<div class="alert alert-danger d-none text-center" id="changePasswordError">Change Password Error</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" onClick="submitChangePassword()" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function submitChangePassword(){
var params = {};
params["id"] = $("#id").val();
params["currentPassword"] = $("#currentPassword").val();
params["newPassword"] = $("#newPassword").val();
params["confirmPassword"] = $("#confirmPassword").val();
$.ajax({
type: "POST",
contentType: "application/json",
url: "/editUser/changePassword",
data: JSON.stringify(params),
dataType: 'text',
cache: false,
timeout: 600000,
success: function (data) {
$("#changePasswordForm")[0].reset();
$("#changePasswordError").addClass( "d-none" );
$("#formSuccess").removeClass( "d-none" );
$("#formSuccess").html("Password Changed successfully!.");
$('#changePasswordModal').modal('toggle');
setTimeout(function(){$("#formSuccess").hide('slow'); }, 2000);
},
error: function (e) {
$("#changePasswordError").removeClass( "d-none" );
$("#changePasswordError").html(e.responseText);
}
});
}
</script>
代码
package com.ABM.aplication.dto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
public class ChangePasswordForm {
@NotNull
Long id;
@NotBlank(message="Current Password must not be blank")
private String currentPassword;
@NotBlank(message="New Password must not be blank")
private String newPassword;
@NotBlank(message="Confirm Password must not be blank")
private String confirmPassword;
public ChangePasswordForm() { }
public ChangePasswordForm(Long id) {this.id = id;}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((confirmPassword == null) ? 0 : confirmPassword.hashCode());
result = prime * result + ((currentPassword == null) ? 0 : currentPassword.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((newPassword == null) ? 0 : newPassword.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ChangePasswordForm other = (ChangePasswordForm) obj;
if (confirmPassword == null) {
if (other.confirmPassword != null)
return false;
} else if (!confirmPassword.equals(other.confirmPassword))
return false;
if (currentPassword == null) {
if (other.currentPassword != null)
return false;
} else if (!currentPassword.equals(other.currentPassword))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (newPassword == null) {
if (other.newPassword != null)
return false;
} else if (!newPassword.equals(other.newPassword))
return false;
return true;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCurrentPassword() {
return currentPassword;
}
public void setCurrentPassword(String currentPassword) {
this.currentPassword = currentPassword;
}
public String getNewPassword() {
return newPassword;
}
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}
public String getConfirmPassword() {
return confirmPassword;
}
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
@Override
public String toString() {
return "ChangePasswordForm [id=" + id + ", currentPassword=" + currentPassword + ", newPassword=" + newPassword
+ ", confirmPassword=" + confirmPassword + "]";
}
}