if(request.getSession().isNew()){
//同步操作
System.out.println("是新的呀呀 呀");
synchronized(this){
count = load(file);
count = count.add(new BigInteger("1"));
save(file, count);
}
}
为什么在servlet内这段不执行呢?
isnew 方法的解释是:如果客户端还不知道该会话,或者客户端选择不加入该会话,则返回 true。例如,如果服务器仅使用基于 cookie 的会话,而客户端已经禁止了 cookie 的使用,则每个请求上的会话都将是新会话。
request.getSession().isNew(),这里判断,if()进不去