gpt4 book ai didi

playframework - 在play 2.3.3中,实体一定要get set?

转载 作者:行者123 更新时间:2023-12-04 05:56:25 24 4
gpt4 key购买 nike

在游戏 2.1.1 中,实体 Login.java:

public class Login {
@NotBlank(message = "login account cannot be empty")
public String mobile;
@NotBlank(message = "login password cannot be empty")
public String password;
public Integer ownInnId;
public InnAdmin admin;
public String token;
}

但在玩 2.3.3 时,发帖有错误:

play.api.Application$$anon$1: Execution exception[[IllegalStateException: JSR-30 3 validated property 'password' does not have a corresponding accessor for data binding - check your DataBinder's configuration (bean property versus direct fie ld access)]] at play.api.Application$class.handleError(Application.scala:296) ~[play_ 2.11-2.3.3.jar:2.3.3] at play.api.DefaultApplication.handleError(Application.scala:402) [play_ 2.11-2.3.3.jar:2.3.3] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun $applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.3.jar: 2.3.3] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun $applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.3.jar: 2.3.3] at scala.Option.map(Option.scala:145) [scala-library-2.11.2.jar:na] Caused by: java.lang.IllegalStateException: JSR-303 validated property 'password ' does not have a corresponding accessor for data binding - check your DataBinde r's configuration (bean property versus direct field access) at play.data.Form.bind(Form.java:349) ~[play-java_2.11-2.3.3.jar:2.3.3] at play.data.Form.bindFromRequest(Form.java:221) ~[play-java_2.11-2.3.3. jar:2.3.3] at controllers.Application.spLogin(Application.java:295) ~[classes/:na] at Routes$$anonfun$routes$1$$anonfun$applyOrElse$132$$anonfun$apply$132. apply(routes_routing.scala:3309) ~[classes/:na] at Routes$$anonfun$routes$1$$anonfun$applyOrElse$132$$anonfun$apply$132. apply(routes_routing.scala:3309) ~[classes/:na] Caused by: org.springframework.beans.NotReadablePropertyException: Invalid prope rty 'password' of bean class [bean.vo.Login]: Bean property 'password' is not re adable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrappe rImpl.java:725) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrappe rImpl.java:716) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.validation.AbstractPropertyBindingResult.getActua lFieldValue(AbstractPropertyBindingResult.java:99) ~[spring-context-4.0.3.RELEAS E.jar:4.0.3.RELEASE] at org.springframework.validation.AbstractBindingResult.rejectValue(Abst ractBindingResult.java:108) ~[spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE] at play.data.Form.bind(Form.java:343) ~[play-java_2.11-2.3.3.jar:2.3.3] [error] application - play onError...POST /spLogin Execution exception[[IllegalS tateException: JSR-303 validated property 'password' does not have a correspondi ng accessor for data binding - check your DataBinder's configuration (bean prope rty versus direct field access)]]

在游戏2.3.3中,实体必须设置好吗?

最佳答案

Play 不会强制您定义 getter/setter。您可以声明和使用它们,也可以直接访问公共(public)字段。

在后台,Ebean 仍会在编译后创建 getter/setter,因此您将无法在代码中使用它们。

关于您的错误,请尝试清理您的项目,然后重新编译:

$ play clean-all
$ play compile

关于playframework - 在play 2.3.3中,实体一定要get set?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25438447/

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