简体   繁体   English

如何每隔X秒使用JSTL调用方法?

[英]How to call a method every X seconds using JSTL?

I have jsp page that displays the entries of a database. 我有显示数据库条目的jsp页面。 I also have a method that scans this database and which deletes the entries that have "expired". 我也有一种方法可以扫描此数据库,并删除“过期”的条目。 This is based on manipulating dates. 这是基于操纵日期的。 I want this method to be called every X seconds in the jsp page using JSTL, so that the entries that have expired are no longer displayed. 我希望使用JSTL在jsp页面中每隔X秒调用一次此方法,以便不再显示已过期的条目。 How would I accomplish this? 我将如何完成?

Once your JSP is loaded on browser, you can not invoke java code. 将JSP加载到浏览器后,您将无法调用Java代码。 So there is no point of having any logic to call method every x seconds through jsp. 因此,没有任何逻辑可以通过jsp每x秒调用一次方法。

However, You can - 但是,您可以-

  1. refresh your jsp every x seconds 每x秒刷新一次jsp

  2. make an ajax call to fetch latest data from DB and display it using javascript/jquery 进行ajax调用以从数据库中获取最新数据并使用javascript / jquery显示它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM