Holle,今天给大家分享的是application&JavaBean
一、applocation
作用于服务器端 类似于全局变量跨用户
//应该先拿值
Integer count=(Integer)application.getAttribute("count");
if(count!=null){//拿到了 说明以前有人访问过
count++;//在原来的访问量上递增1
}
else{
count=1;
}
application.setAttribute("count", count);
二、JavaBean封装
把方法封装在Java Resources的src中
内置对象application 作用于服务器端 类似于全局变量
跨用户
存值:application.setAttribute(键String,值Object)
取值:application.getAttribute(键)
作用域在服务器的打开和关闭之间有效
JavaBean封装java代码
今天的分享就到这里,我们下次再见!