这个功能很简单,但是想起来很方便,很久没用忘记了又会很麻烦,所以做一个记录

网站小功能——人数纪录【流量记录】

count.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String pageName=request.getParameter("pageName");
    Integer count=(Integer)application.getAttribute(pageName);
    if (count==null){
        count=new Integer(0);
    }
    count =new Integer(count.intValue()+1);
    application.setAttribute(pageName,count);
    out.println("页面"+pageName+"的访问次数:"+count);
%>
</body>
</html>

page1.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<jsp:include page="count.jsp">
    <jsp:param name="pageName" value="page1"/>
</jsp:include>
</body>
</html>

 

相关文章:

  • 2021-10-03
  • 2021-12-05
  • 2021-12-15
  • 2021-06-28
  • 2021-09-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-01-12
  • 2021-11-29
  • 2022-12-23
  • 2021-04-29
相关资源
相似解决方案