0
我有以下問題,並且想檢查我是否正確。Jsp會話值
<title>Exam</title>
</head>
<body>
<% Integer times = (Integer)(session.getAttribute("times")) ;
if (times == null) { times = new Integer(0) ; }
else { times = new Integer(times.intValue() + 1) ;
session.setAttribute("times", times) ;}
%>
times = <%=times %>
用戶A首次訪問考試。他收到的頁面顯示times = 0。完成下面的時間= _,假設以下事件完全按照所描述的順序發生。
用戶A在同一瀏覽器窗口中進行第二次訪問考試。他收到回 次= _ _。
用戶B從另一臺計算機首次訪問考試。他收到回退時間= _ _。
用戶A再次從另一臺計算機訪問考試。他收到回 次= _ _。
- 空
- 空
你的意思是通過關閉else塊,我認爲問題是要求「接收回來的時間」是session.getAttribute(「times」)應該是「null」,然後第二個用戶從其他計算機進入? – keivn
上面的代碼將導致編譯錯誤,因爲你的else塊沒有關閉使用} – Subin
固定,但你能回答我的第二個問題嗎? – keivn