This should depend on the specific needs. If you don’t want to exclude duplicates, just add multiple access statistics fields to the article table. Each time there is a visit, add one. If you want to eliminate duplicates, it will involve login and not logged in. The problem requires a special table to sort out the weights. I have never done it. The general idea is this. I hope it helps
Create a variable of type int to save the number of visits, and then save it to the domain of ServletContext, so that all Servlets can access it! Initially, there are no attributes related to the number of visits saved in the ServletContext; When this site is visited for the first time, create a variable count and set its value to 1; save it in the ServletContext; When the site is visited for the first time, When accessed, you can get this variable from the ServletContext, and then add 1 to it. Get the ServletContext object and check whether there is an attribute named count. If it exists, it means it is not the first time to access. If it does not exist, it means it is the first time to access; First time access: call setAttribute( of Servletcontext) ) passes an attribute named count with a value of 1; 2nd to Nth visit: call the getAttribute() method of ServletContext to obtain the original number of visits, add 1 to the number of visits, and then call the setAttribute() method of Servletcontext Complete setup.
If it is really realized, you can borrow the existing wheel:
It is reported that Javascript development frameworks include Clouda, Meteor, Firebase... It can count the number of page visits and update them in real time. I have only used Firebase. The advantages of Firebase are: The API is simple, very convenient to use, and can greatly reduce the amount of code. Data can be managed through the web page, which is very convenient. Supports SSL, authority authentication, and data security mechanisms. ....
This should depend on the specific needs. If you don’t want to exclude duplicates, just add multiple access statistics fields to the article table. Each time there is a visit, add one. If you want to eliminate duplicates, it will involve login and not logged in. The problem requires a special table to sort out the weights. I have never done it. The general idea is this. I hope it helps
Simpler: Page refresh-->Field +1
Complicated: separate table to count visits and determine IP repeatability
Create a variable of type int to save the number of visits, and then save it to the domain of ServletContext, so that all Servlets can access it!
Initially, there are no attributes related to the number of visits saved in the ServletContext;
When this site is visited for the first time, create a variable count and set its value to 1; save it in the ServletContext;
When the site is visited for the first time, When accessed, you can get this variable from the ServletContext, and then add 1 to it.
Get the ServletContext object and check whether there is an attribute named count. If it exists, it means it is not the first time to access. If it does not exist, it means it is the first time to access;
First time access: call setAttribute( of Servletcontext) ) passes an attribute named count with a value of 1;
2nd to Nth visit: call the getAttribute() method of ServletContext to obtain the original number of visits, add 1 to the number of visits, and then call the setAttribute() method of Servletcontext Complete setup.
Static language has this trouble, so let’s use dynamic language to solve it
http://busuanzi.ibruce.info/
If it is really realized, you can borrow the existing wheel:
It is reported that Javascript development frameworks include Clouda, Meteor, Firebase...
It can count the number of page visits and update them in real time.
I have only used Firebase. The advantages of Firebase are:
The API is simple, very convenient to use, and can greatly reduce the amount of code.
Data can be managed through the web page, which is very convenient.
Supports SSL, authority authentication, and data security mechanisms. ....
http://www.jeffjade.com/2015/03/14/2015-03-14-hexo-blog/