本文介绍了在GWT的客户端生成随机代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个java gwt应用程序,我想从客户端验证用户的电子邮件地址,有没有办法在客户端生成随机的5个字符的代码?
解决方案
为什么不用。您可以简单地获取通过它。
以下是生成随机数的有用公式 b
$ b
数字如... ...
pre $ 字符串randomCodes = String.valueOf((int)(Math.random()*(99999 - 1)+ 1)); (randomCodes.length() randomCodes =0+ randomCodes;
。
}
I have created a java gwt application in which I want to verify user's email address from client side, is there any way to generate random 5 character code on client side?
Any sort of help will be appreciated.
解决方案
Why don't you test with Java Math.random() .You can simply get by it.
Here is useful formula for generating random numbers
So , you can generate 5 random numbers as like...
String randomCodes = String.valueOf((int) (Math.random() * (99999 - 1) + 1));
while (randomCodes.length() < 5) {
randomCodes = "0" + randomCodes;
}
这篇关于在GWT的客户端生成随机代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!