因为是web项目,要在程序退出时候,杀死浏览器退出页面,回到windows 界面,所以要在网页点击,退出时候,关闭浏览器,
所以,只能在action 里面执行 windows taskkill 来杀死浏览器进程,如下面/:
Runtime r = Runtime.getRuntime();
try{
Process proc = r.exec("taskkill /f /t /im chrome.exe" );//google 浏览器程序名称
int exitVal = proc.waitFor();
System.out.println(exitVal == 0 ? "成功" : "失败");
}
catch(Exception e){
e.printStackTrace();
}
这样这点击 http://xx/a.do 后,直接关闭浏览器!