当按钮被点击并重定向到父窗口- SpringBoot时,显示一个状态弹出

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

本文关键字:显示 状态 一个 SpringBoot 按钮 重定向 窗口      更新时间:2023-09-26

我已经创建了一个Spring Boot应用程序,当我点击localhost:8080/displayResults

时,它在浏览器上显示以下表
╔═════╦══════╦════════════════════╗
║ ID  ║ Name ║       Action       ║
╠═════╬══════╬════════════════════╣
║ 001 ║ one  ║ start|stop|restart ║
║ 002 ║ two  ║ start|stop|restart ║
╚═════╩══════╩════════════════════╝

我有一个控制器如下

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

上述控制器就是显示上述表格的控制器。

现在我的要求是当我点击start按钮或stop按钮或restart按钮时,它应该调用另一个称为handler.stop()等的方法。该方法检查服务器的现有状态,并相应地启动或停止。此方法需要一段时间(可能是10秒)才能返回状态。在此之前,只要点击"开始或停止或重新启动"按钮,它就会显示一个弹出窗口,然后重定向到相同的父页面。此外,我还需要将IDstart一起传递给控制器,单击

我如何做到这一点?

alert("alert here");

是一个让弹出框出现的简单的js方法

对于其余的,我将使用

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

这是我能想到的最好的了,因为我已经有一段时间没怎么使用js了