简体   繁体   English

是否可以使某些代码不起作用?

[英]Is it possible to make a certain piece of code non functional?

I have set a response refresh header on my Jsp page. 我已经在我的Jsp页面上设置了响应刷新头。 Like : 喜欢 :

<% response.setIntHeader("Refresh",1) ; %>

It makes the jsp refresh at an interval of 1 second. 它使jsp以1秒的间隔刷新。 But I want, that after a certain time is elapsed, the refreshing of the page after 1 second should stop. 但是我想在经过一定时间后,应该在1秒后停止刷新页面。 On a whole refreshing should stop. 总的来说,应该停止刷新。 Is that possible ? 那可能吗 ? I mean making a certain piece of code non functional. 我的意思是使某些代码不起作用。

The only way to make a piece of code or a code block non functional and functional is to wrap them in a conditional statement. 使一段代码或代码块无法正常工作的唯一方法是将它们包装在条件语句中。

In your particular scenario keep a counter to see how many times the page is refreshed, or how much time has passed since the initial refresh (depending on how you want it) and wrap the refresh logic inside a conditional statement to check that the limit is not exceeded. 在您的特定情况下,请保留一个计数器以查看页面被刷新了多少次,或者自初始刷新以来已经过了多少时间(取决于您想要的方式),并将刷新逻辑包装在条件语句中以检查限制是否为不超过。

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

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