[英]Phone number error in struts2
If i give a ten digits number like 1234567891
it works fine, 如果我给一个十位数的数字,例如
1234567891
就可以了,
but why 9964289813
instead doesn't work ? 但是为什么
9964289813
却不起作用?
jsp: jsp:
<s:textfield key="personalDetailsDTO.mobile" label="Mobile" />
dto: dto:
private int mobile;
public int getMobile() {
return mobile;
}
public void setMobile(int mobile) {
this.mobile = mobile;
}
action: 行动:
public class RegisterAction extends ActionSupport{
private PersonalDetailsDTO personalDetailsDTO;
System.out.println(personalDetailsDTO.getMobile());
}
In Java, the max value of an integer is 2,147,483,647
( 2.147.483.647
in my country). 在Java中,整数的
2,147,483,647
是2,147,483,647
(在我的国家/地区为2.147.483.647
)。
You are trying to insert 9,964,289,813
, that is higher. 您试图插入
9,964,289,813
,这是更高的。
That said, phone numbers can contain +
, (
, )
and spaces... don't use a numeric field for a phone number, just use a String. 也就是说,电话号码可以包含
+
, (
, )
和空格...不要为电话号码使用数字字段,只需使用字符串即可。
That does not fit into an int
, as Integer.MAX_VALUE
is 2^32 - 1
. 这不适合
int
,因为Integer.MAX_VALUE
是2^32 - 1
Integer.MAX_VALUE
。 Choose a different data type. 选择其他数据类型。 Phone numbers shouldn't be numbers anyway, they can contain special characters, and start with zeroes.
电话号码无论如何都不应该是数字,它们可以包含特殊字符,并以零开头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.