Foreground picture Call JS function
JS function, which has an important handling, while the open window is closed, the current window refreshes
function Changeurl (element,id) { //alert (element.alt); window.open ("/trip/changeurl?id=" +id); var winobj = window.open ("/portal/trip/changeurl?id=" +id+ "&item=" +element.id+ "&value=" +element.alt, " NewWindow "," height=100, width=800, toolbar =no, Menubar=no, Scrollbars=no, Resizable=no, Location=no, Status=no, top=50 , left=1100 "); var loop = setinterval (function () { if (winobj.closed) { clearinterval (loop); Alert (' closed '); Window.location.reload (); } }, 1); }
Controller End/portal/trip/changeurl
@RequestMapping ("/changeurl") public String Changeurl (Long ID, string item, string value, HttpServletRequest request) { Request.setattribute ("id", id); Request.setattribute ("Item", item); Request.setattribute ("value", value);// SYSTEM.OUT.PRINTLN (ID); return "/tripcontroller/tripurl"; }
Tripurl.jsp, which has a handle, closes the current page after the Save is committed
<form action= "/portal/trip/updatetrip" onsubmit= "Window.opener=null;window.close ();" > <font size= "2" color= "#004779" > Change URL to:</font><br/> <input type= "hidden" Name= "id" id= "id" value= "${id}" > <input type= "hidden" name= "item" id= "Item" value= "${item}" > < Input type= "text" name= "value" id= "value" value= "${value}" style= "color: #95a5a6; padding-left:5px;border-radius:5px; width:700px; height:28px; Vertical-align:middle; " > <input type= "Submit" value= "Save" style= "color: #2c3e50; font-size:12px;font-weight:bold; border-radius:5px; vertical-align:middle;height:30px; width:60px; "/> </form>
Controller End/portal/trip/updatetrip
@RequestMapping ("/updatetrip") public String Updatetrip (Long id,string item,string value,httpservletresponse response {//string result = "{\" result\ ": \" Success\ "}"; try {Urldecoder.decode (value, "Utf-8");} catch (Exception e) { E.printstacktrace ();} Tripservice.updatebyid (Id,item,value); Jsonobject data = new Jsonobject (), try {data.put ("result", "Success"),} catch (Exception e) {System.out.println ( E.getmessage ());} PrintWriter out = null;response.setcharacterencoding ("UTF-8"); Response.setcontenttype ("text/html; Charset=utf-8 "); try { out=response.getwriter (); Out.write (Data.tostring ()); Out.flush (); Out.close (); return null; } catch (IOException e) { e.printstacktrace (); } return "Redirect:/trip/getalltrip";}
window.open Popup Window Call Controller