简体   繁体   English

单击按钮并重定向到父窗口时显示状态弹出窗口-SpringBoot

[英]Display a status popup when a button is clicked and redirect to the parent window - SpringBoot

I have created a Spring Boot application and it displays the following table on the browser when I hit localhost:8080/displayResults 我创建了一个Spring Boot应用程序,当我点击localhost:8080/displayResults时,它在浏览器中显示下表。

╔═════╦══════╦════════════════════╗
║ ID  ║ Name ║       Action       ║
╠═════╬══════╬════════════════════╣
║ 001 ║ one  ║ start|stop|restart ║
║ 002 ║ two  ║ start|stop|restart ║
╚═════╩══════╩════════════════════╝

I have a controller as below 我有一个如下的控制器

@RequestMapping(value = "displayResults", method = RequestMethod.GET)
public ModelAndView getResults(ModelMap model) {
    List<Bean> beanToDisplay = handler.getData();
    return new ModelAndView("Results", "beanToDisplay", beanToDisplay);
}

The above controller is the one that displays the aforementioned table. 上面的控制器是显示上述表格的控制器。

Now my requirement is when I click on the start button or stop button or restart button it should call another method called handler.stop() etc. This method checks the existing status of the server and starts or stops accordingly. 现在我的要求是,当我单击“ start按钮,“ stop按钮或“ restart按钮时,它应调用另一个名为handler.stop()等的方法。此方法检查服务器的现有状态并相应地启动或停止。 It takes sometime (may be like 10 seconds) for this method to return a status. 此方法需要一段时间(可能需要10秒钟)才能返回状态。 Until then it should display a popup as soon as the "start or stop or restart" button is clicked and then redirect back to the same parent page. 在此之前,单击“开始或停止或重新启动”按钮后,它应立即显示弹出窗口,然后重定向回同一父页面。 Additionally I also need to pass the ID to the controller along with the start click 另外,我还需要将IDstart点击一起传递给控制器

How do I achieve this? 我该如何实现?

alert("alert here");

is a simple js way of making a pop up box appear 是使弹出框显示的简单js方法

for the rest i would do something like 对于其余的我会做类似的事情

function myFunction() {
var button //define the button here

 if (button === "GetKeyDown") 
  {
   window.location='http://www.website.com';
   alert("alert here");               
  }
}

this is the best i can think of as i haven't done much with js in a while 这是我能想到的最好的,因为一段时间以来我对js的工作还不多

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

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