需求如下:
      一个商品网站,其上有些商品一天才卖几件。而且买的人非常多。我们的客户是倒卖那个产品的。然而,每天守在那边等,人工不停的按刷新,麻烦呐,一年才多少光阴。然后他的想法是能不能弄个软件,
      1.每几秒自动刷新下页面,然后根据页面提示,如果有该产品就马上停止刷新,并通知用户。如果没有继续刷新。直到产品发布为止。
      2。因为是操作页面的,页面上有个下拉框,还要根据下拉框里面的型号,才能获取产品是否发布,谁有好的解决方案。

解决方案 »

  1.   

    我的想法倒和楼上的兄弟相似,用URLConnection等方式提交参数访问页面,在返回的html中截取数据判断是否有产品
      

  2.   

    可以使用AJAX呀,设置多少时间获取一次产品的发布情况。
      

  3.   


    用AJAX 回调 数据库中商品的数据 比如卖出多少 还剩多少都可以做到 后台无非做的是查询而已。如果你的业务够大 你可以跟电信联系 加接口 还有 手机短信提示 这样并不要整天盯着显示器。
      

  4.   

    页面:JSP代码
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>检测是否有新用户添加</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      <script type="text/javascript">
    var xmlHttpRequest;
    function createXMLHttpRequest() {
    if (window.ActiveXObject) {
    xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
    xmlHttpRequest = new XMLHttpRequest();
    }
    }
    function yzYh() {
    createXMLHttpRequest();
    xmlHttpRequest.onreadystatechange = assignCallBack;
    var url = "yzYh.action";
    xmlHttpRequest.open("post", url, true);
    xmlHttpRequest.setRequestHeader("Content-Type",
    "application/x-www-form-urlencoded");
    xmlHttpRequest.send(null);
    }
    function assignCallBack() {
    if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
    var str = null;
    str = xmlHttpRequest.responseText;
    document.getElementById('allUser').innerHTML = str;
    }
    timer = window.setTimeout("yzYh();",1000*30);
    }</script>
      <body onload="yzYh()">
         目前已经有<div id="allUser"></div>位用户注册
      </body>
    </html>
    我用的是Struts2  这是ACTION代码public String yzYh() throws Exception{
    List<User> users = userService.showAllUsers();//遍历找到所有用户
    String num = "";
    num = users.size()+"";
    PrintWriter out = response.getWriter();
    System.out.println("llllllllllllllllllllllllllllll       "+num);
    if(num != null){
    String str = null;
    str = num;
    out.println(str);
    }
    return null;
    }貌似这个只支持IE   没有谁用AJAX框架  最原始的AJAX