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. In debug it jumps right from the setter to the method so I cannot see anything happening in-between.
我的bean正确使用了一个setter并将属性设置为所需的值,但随后它进入一个使用该属性的方法,它自动被设置为0.我甚至不知道0来自哪里。在调试中,它从setter跳转到方法,所以我看不到中间发生的任何事情。
The bean uses the @SessionScoped
annotation if that has anything to do with it.
如果与它有任何关系,那么bean使用@SessionScoped注释。
1 个解决方案
#1
0
private int vendorno
私人int vendorno
Java primitives like int
, boolean
, long
, etc have a fixed default value.
像int,boolean,long等Java原语具有固定的默认值。
Use wrapper objects instead like Integer
, Boolean
, Long
. They can be null
.
使用包装器对象,如Integer,Boolean,Long。它们可以为空。
private Integer vendorno;
See also:
- Learning the Java Language > Language Basics > Primitive Data Types
学习Java语言>语言基础>原始数据类型
#1
0
private int vendorno
私人int vendorno
Java primitives like int
, boolean
, long
, etc have a fixed default value.
像int,boolean,long等Java原语具有固定的默认值。
Use wrapper objects instead like Integer
, Boolean
, Long
. They can be null
.
使用包装器对象,如Integer,Boolean,Long。它们可以为空。
private Integer vendorno;
See also:
- Learning the Java Language > Language Basics > Primitive Data Types
学习Java语言>语言基础>原始数据类型