当我将以下代码添加到我的项目中时
Form<User> filledForm2 = userSignupForm.bindFromRequest();
它通过显示一条错误消息停止工作:
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的配置?
最佳答案
实际上这不应该发生,因为 Play 会自动生成 getter 和 setter,see Guillaume's comment .
因此,您的 IDE 可能会导致问题,例如Guillaume 对 Eclipse 的评论。或者您的 sbt 缓存已损坏并且需要清理,您可以使用 play clean-all
(read about it here)
顺便说一下,将 Password
属性更改为 password
可能会导致缓存重新生成,从而解决了问题。
更新:
对于使用 activator
的最新版本的 Play,似乎以下是最新的等价物:
activator clean
和 activator clean-files
关于java - Playframework JSR-303 验证 "field"没有对应的数据绑定(bind)访问器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16860046/