[英]display message on a jsp for interval of a minute
I have a message that I am pushing from the controller to the JSP. 我有一条消息,我正在从控制器推送到JSP。 I want to check if the message is not null then display it to the JSP page for a minute.
我想检查消息是否不为null,然后将其显示到JSP页面一分钟。
This is my controller snippet 这是我的控制器片段
ModelAndView mav = new ModelAndView("dashboard");
mav.addObject("message", "Login Successful");
return mav;
I am using it in the view as shown this way 我在这样显示的视图中使用它
<h4 align="center">${message} </h4>
How can I display it for an interval of a minute? 如何显示一分钟的时间?
You can do it in javascript call every minute to your controller which will be in function eg callController(): 您可以在每分钟对您的控制器的javascript调用中完成此操作,该控制器将在函数中,例如callController():
<script type="text/javascript">
setTimeout(function(){ callController() }, 60000);
</script>
*60000 - is minute in milliseconds * 60000-以毫秒为单位
You can use javascript's setTimeout method to call a callback function that can hide the text after 1 minute. 您可以使用javascript的setTimeout方法来调用回调函数,该函数可以在1分钟后隐藏文本。
<h4 align="center" id="msgid">${message} </h4>
<h4 align="center" id="msgid">${message} </h4>
<script type="text/javascript"> setTimeout ( "doSomething()", 60000 );</script>
<script type="text/javascript"> setTimeout ( "doSomething()", 60000 );</script>
Inside doSomething() method write javascript code to hide the text. 在doSomething()方法内部,编写JavaScript代码以隐藏文本。
function doSomething(){ document.getElementById('msgid').innerHTML=''; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.