session.setattribute("rd",new Random().nextInt(100))解释这句意思

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/27 18:18:11
session.setattribute(

session.setattribute("rd",new Random().nextInt(100))解释这句意思
session.setattribute("rd",new Random().nextInt(100))
解释这句意思

session.setattribute("rd",new Random().nextInt(100))解释这句意思
session.setAttribute()知道两个参数可以理解为key,value(键值对)
将value的值存入key字符中.
取出来的时候session.getAttribute(key)取得key对应的value值
new Random().nextInt(100), 0-100之间的数存入"rd字符串中"
session.getAttribute("rd")取得的就是0-100之间的数(取出来是object类型,需要强转)