gpt4 book ai didi

java - 错误 javax.validation.ConstraintViolationException

转载 作者:行者123 更新时间:2023-11-30 07:57:38 26 4
gpt4 key购买 nike

我正在使用 Spring MVC 和 Spring Security 以及 hibernate 。我在保存“密码”时遇到问题无法判断错误在哪里

提交表单时出现以下错误

nested exception is javax.validation.ConstraintViolationException: Validation failed for classes [com.greensungh.jupiter_SHM.model.UsersInfo] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='size must be between 6 and 25', propertyPath=Password, rootBeanClass=class com.greensungh.jupiter_SHM.model.UsersInfo, messageTemplate='{javax.validation.constraints.Size.message}'}
]] with root cause
javax.validation.ConstraintViolationException: Validation failed for classes [com.greensungh.jupiter_SHM.model.UsersInfo] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='size must be between 6 and 25', propertyPath=Password, rootBeanClass=class com.greensungh.jupiter_SHM.model.UsersInfo, messageTemplate='{javax.validation.constraints.Size.message}'}

这是我的观点:

<div class="control-group">
<label class="control-label" for="password">Password</label>
<div class="controls">
<form:password path="Password" id="password"
class="form-control span8" />
<div class="has-error">
<form:errors path="Password" class="help-inline" />
</div></div></div>

模型:

@NotEmpty
@Size(min=6, max=25)
@Column(name="PASSWORD", nullable=false)
private String Password;

我的消息.properties

NotEmpty.userInfo.Password=Password must be blank
Size.userInfo.Password=Password must be between {6} to {25} characters long

任何想法

最佳答案

我遇到了同样的问题。问题是我将密码最大值设置为 30,同时我使用了 bcrypt 编码器。 Bcrypt 对密码进行哈希处理并将其存储为随机的 60 个字符,这违反了最大大小限制。因此,如果您使用加密,请增加您的最大值,以便您的加密密码满足大小要求。我希望这有帮助。

关于java - 错误 javax.validation.ConstraintViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41068615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com