admin管理员组文章数量:1333451
I'm creating a web page using Spring which refreshes the page at regular intervals in order to show up-to-date data. Below is a condensed version of my code which uses Timer for scheduling the refresh after 5 seconds for testing purposes.
@Controller
public class IndexController {
private String id;
private Timer refreshTimer = new Timer();
@GetMapping("/{id}")
public String greeting(@PathVariable String id, Model model) {
this.id = id;
refreshTimer.schedule(new RefreshTask(), 5000L);
return "index";
}
private class RefreshTask extends TimerTask {
@Override
public void run() {
// refresh view
}
}
}
However, about the only information I've found about refreshing views is having a @RequestMapping method return the url prefixed with "redirect:". Is it possible to refresh the view using TimerTask.run() or similar methods without waiting for the view to send a request?
本文标签: spring mvcReloading Sprint MVC view through TimerTaskStack Overflow
版权声明:本文标题:spring mvc - Reloading Sprint MVC view through TimerTask - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742353584a2458974.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论