Playframework JSR-303 验证了“字段"没有对应的数据绑定访问器 [英] Playframework JSR-303 validated "field" does not have a corresponding accessor for data binding

查看:27
本文介绍了Playframework JSR-303 验证了“字段"没有对应的数据绑定访问器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将以下代码添加到我的项目时

When I have added this following code to my project

Form<User> filledForm2 = userSignupForm.bindFromRequest();

它通过显示一条错误消息而停止工作,其中指出:

It has stopped working by showing an error message which states:

Execution exception
[IllegalStateException: JSR-303 validated property 'Password' does not have a corresponding accessor for data binding - check your DataBinder's configuration (bean property versus direct field access)]

我的 User 类是这样的:

class User{
String username;
String Password;
}

现在如何在java play框架中查看/修改DataBinder的配置?

Now how can to check/modify DataBinder's configuration in java play framework?

推荐答案

实际上这不应该发生,因为 Play 会自动生成 getter 和 setter,见纪尧姆的评论.

Actually this shouldn't be happening, as Play automatically generates getters and setters, see Guillaume's comment.

因此,您的 IDE 可能导致问题,例如Guillaume 对 Eclipse 的评论.或者您的 sbt 缓存已损坏并需要清理,您可以使用 play clean-all (在这里阅读)

Therefore it's possible that your IDE is causing issues e.g. Guillaume's comment re Eclipse. Or that your sbt cache is corrupt and needs cleaning, which you can do with play clean-all (read about it here)

顺便说一下,将您的 Password 属性更改为 password 可能会导致重新生成缓存并因此解决了该问题.

By the way, changing your Password attribute to password may have caused the cache to be re-generated and therefore fixed the issue.

更新:

对于使用 activator 的较新 Play 版本,以下似乎是最新版本:

For more recent versions of Play that use activator, it seems the following are the the up-to-date equivalents:

activator cleanactivator clean-files

这篇关于Playframework JSR-303 验证了“字段"没有对应的数据绑定访问器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆