需求:根据数据库情况,在页面定时弹出相应的消息

实现:

  1. 展示DIV设置

<script language="javascript" type="text/javascript" src="${ctx}/ui/js/jquery-1.3.2.js" > </script>
<style>
div{padding-right:5px;
padding-top:5px;
}
#note{position:absolute;width:300px;height:150px;padding:20px;background:#eee;border:1px solid #ccc;left:72%;z-index:9999;display:none;}
</style>
<link rel="stylesheet" href="${ctx}/sdc/ext/finance/finance/ui/home/themes/default/css/list.css" type="text/css">
<link rel="stylesheet" href="${ctx}/sdc/ext/finance/finance/ui/home/themes/default/css/template.css" type="text/css">
<div id="note" style="padding-left:5px;padding-right:5px;padding-top:5px;background:url(${ctx}/sdc/ext/finance/finance/ui/home/themes/default/img/tz.gif) repeat-x;">
<div style="height: 20px;">
<table width="98%" align="center" border="0">
<tr style="width: 100%">
<td align="left"><b>消息提醒</b></td>
<td align="right"><a onClick="closeMsg()">关闭</a><img id="closeBtn" src="${ctx}/sdc/ext/finance/finance/ui/home/themes/default/img/close.png" alt="关闭" onClick="closeMsg()" /></td>
</tr>
</table>
</div>
<div id="showInfo" style="width: 300px;height: 160px;">
</div>
</div>

  2. js调用ajax,确定页面是否弹出。

  2.1  使用window.setInterval(参数1,参数2),设置定时器,参数1为调用的方法,参数2为调用间隔时间,单位为毫秒

  2.2  window.clearInterval(interval);可以清除设置的定时器,interval为方法参数

var num = 10;
var showCount = 3;
var currCount = 0;
var lClientID = document.getElementById('agencyName').value;
var interval = window.setInterval(showMsgIcon, 1000*num);
function showMsgIcon(){
if(currCount-showCount==0){
window.clearInterval(interval);
}
if(!$('#note').is(':visible')){
$.ajax({
type: "POST",
url: "${ctx}/QueryTodoTaskServlet",
data: "agencyId="+lClientID+"&userId=<%=userInfo.getUserId()%>",
success: function(returnValue){ if(returnValue!="")
{
currCount ++;
//var msgPicFadeOutIn = setInterval(function(){
var divshow = $("#showInfo");
divshow.text("");// 清空数据
var currencyArray = returnValue.split("#");
for(var i=0;i<currencyArray.length-1;i++)
{
var currency = currencyArray[i].split(",");
var curName = currency[0];
var curCount = currency[1]; var urlEbank = "http://10.28.53.226:9085/ebankDraft/draft/query/transactionflowquery/transactionFlowQuery.jsp?funcid=000010000500003359370361203264&isOp=0&MGHessianURL=http://127.0.0.1:9085/toftmerge/MGHessianServlet&MGAppName=toftmerge&MGIntSysId=00000000000000000587557608475672&RLOGINPATH=ebank_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=359370361203264&lClientID="+lClientID;
if(i==0){
divshow.append(curName+'结算菜单<a onclick ="clickB()">'+curCount+'</a>条');
}else{
divshow.append("<br/>"+curName+'结算菜单<a onclick ="clickB()">'+curCount+'</a>条');
}
divshow.append("<br/>银企菜单<a onclick ='clickA()' >200</a>条"); // 添加Html内容,不能用Text 或 Val
divshow.append("<br/>电票菜单<a onclick='clickC()'>300</a>条");
divshow.append("<br/>纸票菜单<a onclick='clickD()'>400</a>条");
}
if(!$('#note').is(':visible')){
$('#note').css({display:'block', top:(sheight-50)}).animate({top: (sheight - 200)}, 500);
}
// }, 10000);
}else{
//sheight = $(window).height()
//$('#note').css({'top':(sheight - 210)});
}
}
});
} }
function clickB(){
selectModule1(1);
var main = document.getElementById('main');
main.src="http://<%=localHost1%>:<%=localPort1%>/NASApp/iTreasury-settlement/settlement/tran/current/view/v021.jsp";
// window.showModalDialog("http://10.28.53.226:9085/NASApp/iTreasury-settlement/settlement/tran/current/view/v021.jsp","", "dialogWidth=800px;dialogHeight=450px");
}
function clickA(){
//var tree = document.getElementById('tree');
//tree.src = "http://<%=localHost1%>:<%=localPort1%>/toftmerge/finance/getModule.do?currencyId=1&RLOGINPATH=finance_session_outdate&unitId=1&random=" + new Date().getTime();
selectModule1(12);
// flushMain();
// alert(1);
var main = document.getElementById('main');
main.src="http://<%=localHost1%>:<%=localPort1%>/NASApp/iTreasury-bankportal/bankinterface/view/v001.jsp?funcid=12000040000112&isOp=1&MGHessianURL=<%=MGHessianURL%>&MGAppName=toftmerge&MGIntSysId=1001&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=12";
// window.showModalDialog("http://10.28.53.226:9085/NASApp/iTreasury-bankportal/bankinterface/view/v001.jsp?funcid=12000040000112&isOp=1&MGHessianURL=http://127.0.0.1:9085/toftmerge/MGHessianServlet&MGAppName=toftmerge&MGIntSysId=1001&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=12","", "dialogWidth=800px;dialogHeight=450px");
}
function clickC(){
selectModule1(404291396468369);
var main = document.getElementById('main');
main.src="http://<%=localHost1%>:<%=localPort1%>/NASApp/DraftManage-finance/draftQuery/draftOperationProcessQuery/v001.jsp?funcid=000010000500004404291396468369&isOp=0&MGHessianURL=<%=MGHessianURL%>&MGAppName=toftmerge&MGIntSysId=00000000000000000404291396468383&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=404291396468369"; // window.showModalDialog("http://10.28.53.226:9085/NASApp/DraftManage-finance/draftQuery/draftOperationProcessQuery/v001.jsp?funcid=000010000500004404291396468369&isOp=0&MGHessianURL=http://127.0.0.1:9085/toftmerge/MGHessianServlet&MGAppName=toftmerge&MGIntSysId=00000000000000000404291396468383&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=404291396468369","", "dialogWidth=800px;dialogHeight=450px");
}
function clickD(){
selectModule1(898586663909326);
var main = document.getElementById('main');
main.src="http://<%=localHost1%>:<%=localPort1%>/financeDraft/draft/query/transactionflowquery/transactionFlowQuery.jsp?funcid=000010000600004898586663909326&isOp=0&MGHessianURL=<%=MGHessianURL%>&MGAppName=toftmerge&MGIntSysId=00000000000000000898586663909324&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=898586663909326"; // window.showModalDialog("http://10.28.53.226:9085/financeDraft/draft/query/transactionflowquery/transactionFlowQuery.jsp?funcid=000010000600004898586663909326&isOp=0&MGHessianURL=http://127.0.0.1:9085/toftmerge/MGHessianServlet&MGAppName=toftmerge&MGIntSysId=00000000000000000898586663909324&RLOGINPATH=finance_session_outdate&UnitId=<%=unitId%>&SDCsessionId=<%=request.getSession().getId() + userInfo.getUuid()%>&module_id=898586663909326","", "dialogWidth=800px;dialogHeight=450px");
}
function out(){
$('#note').animate({top:(sheight-50)}, 500, function(){
$(this).css({display:'none', top:'-100px'});
});
}

后台:

servlet

package com.iss.sdc.ext.finance.finance.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.iss.sdc.ext.finance.finance.util.TodoTaskUtils;
import com.toft.core2.ToftException; public class QueryTodoTaskServlet extends HttpServlet{ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
doPost(req, resp);
} protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
String temp = "";
String agencyId = "";
String userId = "";
String returnValue = "";
String currencyId = "";
String name = "";
temp = req.getParameter("agencyId");
if ((temp != null) && (temp.trim().length() > 0))
{
agencyId = temp;
}
temp = req.getParameter("userId");
if ((temp != null) && (temp.trim().length() > 0))
{
userId = temp;
} TodoTaskUtils todoTaskUtils = new TodoTaskUtils();
Map map = new HashMap();
List list = todoTaskUtils.queryTodoTaskList(userId, agencyId);
Iterator it = list.iterator();
while (it.hasNext())
{
map = (HashMap)it.next();
currencyId = (String)map.get("COUNT");
name = (String)map.get("NAME");
returnValue = returnValue + name + "," + currencyId + "#";
}
System.out.println("returnValue========"+returnValue);
resp.setContentType("text/html;charset=UTF-8");
resp.setHeader("Cache-Control", "no-cache");
PrintWriter out = resp.getWriter();
out.print(returnValue);
out.flush();
out.close();
}catch (ToftException e) {
e.printStackTrace();
}
}
}

web.xml

        <servlet>
<servlet-name>QueryTodoTaskServlet</servlet-name>
<servlet-class>com.iss.sdc.ext.finance.finance.servlet.QueryTodoTaskServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>QueryTodoTaskServlet</servlet-name>
<url-pattern>/QueryTodoTaskServlet</url-pattern>
</servlet-mapping>

jsp页面访问数据库根据数据情况,定时弹出提醒的更多相关文章

  1. jsp页面显示数据库的数据信息表

    在日常jsp开发中:最基本的一个操作之一是把之前添加到数据库中的信息在jsp页面中显示出来,也就是增删改查中的查找的一部分: 下面是以上部分的开发步骤及分析. 1.在jsp页面: <thead& ...

  2. jsp页面不乱码,外部引用的js弹出对话框乱码

    今天在做一个课程设计的时候,写到一个界面注册,在用js判断数据的正确性时,碰到了一个js弹出框的乱码问题.在网上找寻了很久,也找了很多博客看,但是发现怎么样都不能解决我的问题,下面给出几个比较经典的解 ...

  3. 360浏览器兼容模式下jsp页面访问不到js文件

    360浏览器兼容模式下jsp页面访问不到js文件 查看自己js中的语法问题,不要用ES6的语法,编译不了故找不到js文件 const var of 码出高效 java 比较 所有整型包装类对象之间值的 ...

  4. 自建目录中jsp页面访问servlet路径出错404

    ---恢复内容开始--- 自建目录中jsp页面访问servlet路径出错404 使用eclipse建立的项目,总是会遇到路径问题,比如jsp页面访问servlet,jsp在默认的路径.jsp在自建目录 ...

  5. JSP中访问数据库

    在JSP中访问数据库使用的是JSTL标签,本文不按照http://wiki.jikexueyuan.com/project/jsp/database-access.html此方法进行实践,而是采用之前 ...

  6. Spring Boot Web项目整合jsp页面访问

    这个内容就是实操过程中各种访问不了jsp页面,各种尝试后的解决方案吧.可能不是最优的,但是目前能解决项目中的一些问题.之前觉得没有什么问题直接可以操作的,没想到在这部分还是耗时了. 开发工具idea2 ...

  7. jQuery学习(二)——使用JQ完成页面定时弹出广告

    1.JQuery效果 2.步骤分析: 第一步:引入jQuery相关的文件 第二步:书写页面加载函数 第三步:在页面加载函数中,获取显示广告图片的元素. 第四步:设置定时操作(显示广告图片的函数) 第五 ...

  8. JavaScript学习——使用JS完成页面定时弹出广告

    1.获取图片的位置(document.getElementById(“”))  隐藏图片:display:none 定时操作:setInterval(“显示图片的函数”,3000); 2.步骤分析 ( ...

  9. 【JavaScript】案例三:使用JS完成页面定时弹出广告——事件(onload)

     事件(onload) *注意点: 变量加var局部变量,不加var全局变量 setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭. 返回值:返回 ...

  10. JS应用实例3:定时弹出广告

    在观看视频时候总会发现有广告弹出 这里就做一个类似这样的定时弹出广告的实例: 前面的JS代码和HTML写在同一个文件,实际开发中总是分开来写 用的时候引入即可 HTML代码: <!DOCTYPE ...

随机推荐

  1. Git/Github的基本操作

    由于我之前已经安装好了Git,然后这里就不再叙述之前的相关创建账户的步骤了.直接记录一下如何在本地创建一个项目,并上传到github上面. 1.打开github官网,点击New Repository, ...

  2. Elsa V3学习之脚本

    在前面的文章中,可以看到我们经常使用JS脚本来获取变量的值.在Elsa中是支持多种脚本的,最常用的基本是JS脚本和C#脚本. 本文来介绍以下这两个脚本使用. Javascript 在ELSA中的jav ...

  3. ubuntu 安装psycopg2包

    psycopg2 库是 python 用来操作 postgreSQL 数据库的第三方库. 执行:pip3 install psycopg2==2.8.4 有可能会报错: Collecting psyc ...

  4. 安装部署harbor

    配置文件中修改内容hostname 和 证书 私钥 需要指定到文件 hostname: hub.rainsc.com # http related config http: # port for ht ...

  5. 一个Java类在运行时候,变量是怎么在JVM中分布的呢?

    JVM学习第三篇思考:一个Java类在Jvm内存中是怎么存在的 又名:Java虚拟机的内存模型(JMM)是什么样的. 通过前面两篇文章的学习,我们知道了一个Java类的生命周期及类加载器.我们可以得到 ...

  6. Seata 1.3.0 ERROR i.s.c.r.n.NettyClientChannelManager -no available service 'null' found, please make sure registry config correct

    根据个人经验,报这个错误是因为nacos里并没有同步seata的config导致的 配置文档:https://www.bookstack.cn/read/seata-1.3.0/4b2f4de4831 ...

  7. 非常简易的SpringBoot后台项目

    非常简易的SpringBoot后台项目 1. 创建项目 使用IDEA创建 Spring项目,或在 https://start.spring.io/ . https://start.aliyun.com ...

  8. ptmalloc2涉及的基础知识与基本数据结构

    随笔来源:ctfwiki CSDN 本随笔只为记录分析总结的自己学习的结论,方便未来回顾,以及为他人提供一个理解的思路,不保证正确.如有谬误,请大家指出. 1.堆相关的操作 malloc:返回对应大小 ...

  9. SimMTM: 用于掩码时间序列建模的简单预训练框架《SimMTM: A Simple Pre-Training Framework for Masked Time-Series Modeling》(预训练模型、时序表征学习、掩码建模、流行学习、近邻聚合、低级表示学习(掩码)、高级表示学习(对比)、segment-wise 和point- wise)

    今天是2024年7月3日10:15,写一篇1月7日就看过的论文,哈哈哈哈哈哈哈哈哈,突然想到这篇论文了. 论文:SimMTM: A Simple Pre-Training Framework for ...

  10. CSS – ellipsis and line-clamp

    前言 CSS 很早就有 build-in 方案 for 省略号 ellipsis 了. 但是只能 one line, 遇到多行的时候只能用 JS. 后来出了 line-clamp 终于把 multip ...