search

Home  >  Q&A  >  body text

java - 如何实现网站访问次数记录

各位大佬好,小弟现在对一个问题比较迷惑,如何统计网站的访问次数,目前使用的技术方案是SSM(spring+springmvc+mybatis),不知道这个功能应该是实现在哪里,请各位赐教。

阿神阿神2813 days ago748

reply all(5)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:56:45

    1. If there is a reverse proxy tool such as nginx, you can directly hand it over to nginx for statistics.
    2. You can use the servlet interceptor to intercept the required statistical requests, and then classify or summarize statistics as needed.
    3. You can use servlet filters to filter requests that require statistics, same as above.
    4.Spring aop is also a good choice.
    5. If it is a js script, requests that do not need to access the page cannot be counted.
    6. Statistics of container access logs.

    If there is load balancing, 23456 needs to be summarized at the end, which is more troublesome.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:56:45

    Website access records? You can use Baidu’s statistical tool and just add that Js code to the public part of the page

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:56:45

    Write an interceptor in spring. Record each visit.
    Or use third-party tools such as Baidu to embed the script directly

    reply
    0
  • 阿神

    阿神2017-04-18 10:56:45

    I will talk about a relatively primitive method, write an HttpSessionListener, maintain a static access count variable, +1 every time a session is created, of course you must pay attention to multi-threading issues

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:56:45

    Just use application

    reply
    0
  • Cancelreply