Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对网络服务中的一个问题感到震惊。我有一个计数变量声明为 bean 中的成员变量。每次调用 web 服务时,我都会增加 count 的值。新会话的 count 变量未设置为零。它继续为新会话增加。你能告诉我如何将计数的值设置为零。
你可以使用这个:
HttpSession session = request.getSession(); if (session.isNew()) { count = 0; }