[英]Bean property being set to 0
My bean is correctly using a setter and sets the property to the desired value, but then it enters into a method which uses the property and it is automatically being set to 0. I don't even know where the 0 is coming from. 我的bean正确地使用了setter并将属性设置为所需的值,但是随后它进入使用该属性的方法,并且该属性自动设置为0。我什至不知道0的来源。 In debug it jumps right from the setter to the method so I cannot see anything happening in-between.
在调试中,它从设置器直接跳转到方法,因此我看不到它们之间发生了什么。
The bean uses the @SessionScoped
annotation if that has anything to do with it. 这个bean使用
@SessionScoped
注释如果有什么关系呢。
private int vendorno
私人int供应商
Java primitives like int
, boolean
, long
, etc have a fixed default value. Java原语(例如
int
, boolean
, long
)具有固定的默认值。
Use wrapper objects instead like Integer
, Boolean
, Long
. 使用包装对象,例如
Integer
, Boolean
, Long
。 They can be null
. 它们可以为
null
。
private Integer vendorno;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.