window.open Popup Window Call Controller

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.