Przeglądaj źródła

Merge branch 'master' of https://e.coding.net/kuilian/devicmanagement.git

kuilian 6 lat temu
rodzic
commit
d28bd7d861
2 zmienionych plików z 71 dodań i 0 usunięć
  1. 39 0
      Mysql/WebRoot/Ajax.html
  2. 32 0
      Mysql/WebRoot/visit.jsp

+ 39 - 0
Mysql/WebRoot/Ajax.html

@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<script type="text/javascript">
+	function ajaxFunction()
+{
+  var xmlhttp;
+  //判断浏览器
+  if (window.XMLHttpRequest)
+  { 
+    xmlhttp=new XMLHttpRequest();
+  }
+  else
+  {   
+    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+  }
+  //每当readyState 改变时,就会触发 onreadystatechange 事件
+  xmlhttp.onreadystatechange=function()
+  {
+    if (xmlhttp.readyState==4 && xmlhttp.status==200)
+    {
+      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
+    }
+  }
+  //XMLHttpRequest.open('post', url, true);
+  xmlhttp.open("post","visit.jsp",true);
+  //在利用xmlhttp的send()提交表格,并且需要在服务器端通过request.getParameter("paraName")来就收的话,先要加入header参数
+  xmlhttp.send();
+}
+	
+</script>
+</head>
+<body>
+
+<button type="button" onclick="ajaxFunction()" >点击刷新访客量</button>
+<div id="myDiv"></div>
+
+</body>
+</html>

+ 32 - 0
Mysql/WebRoot/visit.jsp

@@ -0,0 +1,32 @@
+<%@ page contentType="text/html; charset=UTF-8" 
+pageEncoding="UTF-8" %>
+<% response.setContentType("text/html");
+   response.setHeader("Pragma","No-cache");
+   response.setHeader("Cache-Control","no-cache");
+   response.setDateHeader("Expiress",0); %>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+
+    
+    <title>java计数器</title>
+   
+
+
+  </head>
+  
+  <body>
+    <%
+    if(application.getAttribute("count")==null){
+    	application.setAttribute("count", new Integer(0));
+    }
+    Integer count=(Integer)application.getAttribute("count");
+    application.setAttribute("count", new Integer(count.intValue()+1));
+    count=(Integer)application.getAttribute("count");
+     %><div id="aaa">	这是第
+     <%=count.intValue()%>个访问量
+
+ </div>   
+  </body>
+</html>